sqlserver临时启用和关闭约束


select  'ALTER TABLE ['  + b.name +  '] NOCHECK CONSTRAINT ' +  a.name +';' as  禁用约束   
from  sysobjects  a ,sysobjects  b     
where  a.xtype ='f' and  a.parent_obj = b.id


select  'ALTER TABLE [' + b.name +  '] CHECK CONSTRAINT ' +  a.name +';' as  启用约束     
from  sysobjects  a ,sysobjects  b     
where  a.xtype ='f' and  a.parent_obj = b.id

原文地址:https://www.cnblogs.com/grokyao/p/3240054.html