Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Bulk Insert Huge CSV with eerrors

Author  Topic 

patelb
Starting Member

16 Posts

Posted - 2008-08-25 : 14:33:34
I have a huge CSV file that I need to insert into a table. I am able to insert the file into the table but i have to set maxerrors=1000 for example because there are bad records that dont match the table column mapping in the CSV file. Is there a way that I can only insert the records that do match the table schema and seperate out the ones that dont?

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-08-26 : 03:58:36
Is there a consistent cause to the error(s). Are they all field truncation? / datatype mismatch? etc.

-------------
Charlie
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-26 : 04:24:51
Insert into staging table first.
Then use only the valid records for insert to target table.

Or do the csv file have different number of columns for every row?

My favorite answer,
http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
because we have no idea how the csv file looks like.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -