简体   繁体   中英

Bulk Insert Error Messages SQL Server 2008 R2

Is there any way to capture the error messages that occur during a bulk insert?

If I specify an error file, I get 2 seperate files, one that contains the record that errored, and one that contains the row.

The messages that are displayed for errors contain more information:

Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 6 (temp_batch_date).

Is it possible to write these messages into a temp table so I can handle them accordingly?

Check out the SqlBulkCopy class to perform the operation and you should have programmatic access to any errors (exceptions) that are generated. This should allow you to attempt recovery/logging.

If you don't want to use Visual Studio (why not? it's free ), you could also use PowerShell .

Handling these errors outside of SQL Server really opens up what/how you can workaround hurdles with your source data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM