November 12, 2009 at 2:34 pm
Hi All,
Can anyone tell me the best way to not import the final two rows of a CSV file?
I have a foreach loop container that imports the CSV files into one SQL Server database, however I do not want to import the final two rows of the file as these are control file rows.
Many thanks in advance for your support.
Regards,
Chris
November 12, 2009 at 6:06 pm
Do they prevent file from being loaded? If not, I guess you can use conditional split to separate them from the rest of the rows.
Regards
Piotr
...and your only reply is slàinte mhath
November 13, 2009 at 1:43 am
Hi Piotr,
Yes they prevent the file from being loaded.
Regards,
Chris
November 13, 2009 at 9:09 am
add a vbscript task before the actual import and open the csv file and delete the last 2 rows and save the file. Then import it and you should be good.
November 13, 2009 at 9:12 am
Hi hamzajosh,
Thanks for your suggestion. How would I delete the final two rows in VB?
Chris
November 13, 2009 at 11:07 am
I cheat like hell on this type of thing. When I have to do such a thing, I make a BCP format file and either use BCP or BULK INSERT with a max allowed errors setting of 1 or 2 depending on the failure mode that the last 2 lines cause.
All of that information is located in Books Online under BCP. BCP format files work exactly the same way for either BCP or Bulk Insert.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy