Disable and Enable Constraint Checking on SQL Server Tables
Found this script to disable/enable constraint checking here :
SELECT 'ALTER TABLE ' + object_name(parent_obj) +
' NOCHECK CONSTRAINT ' + name
FROM sysobjects
WHERE xtype = 'F'
ORDER BY object_name(parent_obj)
and to enable:
SELECT 'ALTER TABLE ' + object_name(parent_obj) +
' WITH CHECK CHECK CONSTRAINT ' + name
FROM sysobjects
WHERE xtype = 'F'
ORDER BY object_name(parent_obj)
Cool!
Comments
- Anonymous
December 28, 2007
PingBack from http://msdnrss.thecoderblogs.com/2007/12/28/disable-and-enable-constraint-checking-on-sql-server-tables/