When does SqlBulkCopy check for constraints?

constraints sqlbulkcopy sql-server-2005

Question

If SqlBulkCopyOptions.CheckConstraints option is set for SqlBulkCopy insert, does it check the constraints separately after each record, or after all records are inserted?

I have a check constraint that compares some columns to the parent row (through a UDF). I'm using MS Sql Server 2005. The documentation at http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopyoptions.aspx only says "Check constraints while data is being inserted."

In my tests it seems that foreign keys are not checked until the end, but check constraints are checked for each row before adding the next one. This sounds quite odd. I haven't found any documentation about this.

1
4
9/28/2009 3:42:45 PM

Popular Answer

Not sure, if I understand this completely.

But, that could be because of transaction in place. It might check for foreign key constraints, when it is ready to commit, as against column constraints which can be checked independently (somewhat).

0
9/28/2009 3:48:09 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