Posts Tagged ‘Bulk Update ignoring trigger’

Some time its required we have to INSERT/UPDATE some bulk data, and due to particular Constraints, it work as a barrier to prevent as per constrains behavior. We can set the constraints on a perticular table / column to not check temporarily, then re-enable the constraints as
ALTER TABLE TableName NOCHECK CONSTRAINT ConstraintName
Then re-enable constraints using-
ALTER 
TABLE TableName CHECK CONSTRAINT ConstraintName

If its required to Disable all constraints from all of Tables of Current Database, for same we can use

–Disable all Constraints
EXEC sp_MSforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT ALL’
–Enable all Constraints
EXEC sp_MSforeachtable ‘ALTER TABLE ? CHECK CONSTRAINT ALL’