September 13, 2002 at 10:26 am
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.
September 16, 2002 at 11:11 am
Load into a dummy table and then move it for rows that have enough non-NULL values?
Steve Jones
http://qa.sqlservercentral.com/columnists/sjones
Follow me on Twitter: http://www.twitter.com/way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply