September 26, 2013 at 8:37 am
I want to use BCP to load data from a text file.
By default, constraints are turned off in bcp, so I use the CHECK_CONSTRAINTS hint.
bcp aborts if ANY of the rows contains a FK violation. No data get loaded.
So if I add the -b 1 batch size option, it loads all data UNTIL the first FK violation, but nothing after that.
I want to load EVERYTHING ... except for the violations. But bcp won't let me. Is there a way?
September 26, 2013 at 9:19 am
I'm not sure if bcp would allow you to do that. However, you could load all data to a staging table and insert clean data into your final table to avoid PK violations.
November 27, 2013 at 1:06 pm
bruce.malmat (9/26/2013)
I want to use BCP to load data from a text file.By default, constraints are turned off in bcp, so I use the CHECK_CONSTRAINTS hint.
bcp aborts if ANY of the rows contains a FK violation. No data get loaded.
So if I add the -b 1 batch size option, it loads all data UNTIL the first FK violation, but nothing after that.
I want to load EVERYTHING ... except for the violations. But bcp won't let me. Is there a way?
Yes, there is. If you take a look in Books Online for the BCP command, you'll find that the -m parameter changes the number of allowable errors. You can also use the -e parameter to identify a file where the error rows can be stored for validation and rework. Set the batch size back to at least 50,000, set -m to a very large number (like 2 billion), and let 'er rip.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply