Finding the rows that caused the constraint failure

constraints datatable sqlbulkcopy sql-server

Question

Any idea if it's possible to get a list of the trouble making rows in an INSERT/UPDATE statement when a constraint test fails?

I'm trying to insert data with an SQLBulkCopy object reading data from a DataTable, and when the constraint fails I have no way of telling which rows caused the issue. The DataTable is quite large, and is actually data from an XML file so I can't really run a SELECT statement against that source to find rows that match the constraint's selection criteria.

Thx!

1
0
5/15/2012 7:39:32 PM

Popular Answer

FYI Could not find a way to get this info from the framework, so built a helper class that can retrieve all the errors and related data rows when a SqlBulkCopy process fails. See here for details: http://www.codeproject.com/script/Articles/ArticleVersion.aspx?waid=13789&aid=387465

0
5/18/2012 8:46:31 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow