710661809 发表于 2016-11-1 09:03:14

SQL Server 关闭及开启所有约束

sql 代码

[*]declare @tbname varchar(250)   
[*]declare #tb cursor for select name from sysobjects where objectproperty(id,'IsUserTable')=1   
[*]open #tb   
[*]fetch next from #tb into @tbname   
[*]while @@fetch_status=0   
[*]begin  
[*]  exec('alter table ['+@tbname+'] nocheck constraint all')    
[*]  -- nocheck关闭所有约束 check开启所有约束   
[*]  fetch next from #tb into @tbname   
[*]end  
[*]close #tb   
[*]deallocate #tb  
页: [1]
查看完整版本: SQL Server 关闭及开启所有约束