ALTER TABLE permission is required on the target table of a bulk copy operation if the table has triggers or check constraints, but 'FIRE_TRIGGERS' or 'CHECK_CONSTRAINTS' bulk hints are not specified

This is the SqlBulkCopy bulk copy abnormalities caused this problem when it comes to bulk import data, control the bulk-import operation is performed (trigger) trigger. Bulk import operation should be performed only for the trigger table row insert comprising a plurality of supports and INSTEAD OF INSERT triggers.

 

SqlBulkCopy (insert bulk) command statement in the trigger is disabled by default, you can enable FIRE_TRIGGERS; error "if a bulk copy operation the target table has triggers or check constraints, without specifying" fire_triggers "or" check_constraints "big capacity prompt, you need to have the "alter table" permission on the table "and has been described does not specify fire_triggers target table has a trigger, you can specify SqlBulkCopyOptions.FireTriggers enabled statement:. SqlBulkCopy sqlbulkcopy = new SqlBulkCopy (connectionString, SqlBulkCopyOptions. UseInternalTransaction | SqlBulkCopyOptions.FireTriggers).

So far, the cause of the abnormality and the solution is.

 

In addition, MSDN indicates whether "when bulk import data, you can control the bulk-import operation is performed (trigger) trigger. Bulk import operation should only be performed on the table contains a trigger to support multi-row inserts INSERT and INSTEAD OF triggers "so there is a requirement for a trigger, one insert trigger, and second, instead of.

After figuring out above, it is another topic: insert multiple pieces of data, if necessary, require the use of trigger cursor to the desired function.

 

Guess you like

Origin www.cnblogs.com/Juning/p/10986343.html