November 12, 2003 at 4:53 pm
I'm writing a DTS to import a comma delimited file. Unfortunately not all the records have the correct number of columns. How can I check the number of columns and skip the incorrect ones?
Ta
November 13, 2003 at 4:35 am
You will have to hand parse it with ActiveX by opening each line from the file and verifying the conditions that make it a valid record, split it and post to database. I have no code I can provide at this time, hopefully someone will post an example.
November 13, 2003 at 7:22 am
In SQL7 DTS, if you use a test file with the maximum number of columns and define the properties of the file, then when you use real data file, sql will import the data irrespective of the number of columns specified (as long as each line is terminated correctly) and will insert null where no column is specified. You can then check the data for null columns.
Obviously this will only work if you have no empty columns in the 'valid' data.
Far away is close at hand in the images of elsewhere.
Anon.
November 13, 2003 at 9:36 am
I do this in SQL 2000...then simply do a delete query on my table right after the records are imported, removing those records where the end columns are null.
Michael Weiss
Michael Weiss
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply