I have a need to validate a file and part of this validation is to count how many columns exist in each row (tab-delimited).
I have tried using the following, which works in most (but not all) cases (example using , as the delimiter for display reasons).
SELECT * -- Errors
FROM testTable
WHERE testLine NOT LIKE '%,%,%,%,[^,]%'
to check for 5 columns
Things fall apart once you have a few columns with nothing in them, inc the last column.
Can anyone suggest a good, preferably set-based method to use instead? I would rather not go down the CURSOR, SUBSTRING route.
Many thanks for any suggestions - have a good weekend.