SqlBulkCopy批量插入数据时,不执行触发器和约束的解决方法
在new SqlBulkCopy对象的时候,设置一下SqlBulkCopyOptions选项即可,按位或运算
SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.CheckConstraints
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(GlobalString.ConnectionString, SqlBulkCopyOptions.CheckConstraints | SqlBulkCopyOptions.FireTriggers)) { //........... }