Jaa


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