I have a table with a trigger newly added to it.
When I try to run a batch file and upload the file using SqlBulkCopy it did not work.
After reading that addin
I tried adding Checkconstraints as well but it says the same error.
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.CheckConstraints))
Is there another way to do it?
SQL Server requires ALTER TABLE
permissions to bulk insert data without the FireTriggers and CheckConstraint options, as well as with the KeepIdentity option, to help safeguard against minimally-privileged users from violating data integrity rules enforced by SQL Server. See What permission do I need to use SqlBulkCopy in SQL Server 2008?.
The FireTriggers and CheckConstraint options of SqlBulkCopy are off by default to maximize performance. It is the application's responsibility to ensure data integrity that would otherwise be enforced by constraints and triggers when these options are off. Foreign key and check constraints become not trusted after data are bulk copied without these options and must be re-validated with ALTER TABLE...CHECK CONSTRAINT` afterwards before SQL Server will trust the constraints again.
No special permissions other than SELECT/INSERT
to use SqlBulkCopy when FireTriggers and CheckConstraint options are on, and the KeepIdentity option is off.