您的位置:首页 > 博客中心 > 数据库 >

SQLServer 删除所有表的外键约束

时间:2022-03-10 17:50

DECLARE c1 cursor for    
select ‘alter table [‘+ object_name(parent_obj) + ‘] drop constraint [‘+name+‘]; ‘
from sysobjects
where xtype = ‘F‘
open c1declare @c1 varchar(8000)
fetch next from c1 into @c1while(@@fetch_status=0)
begin
exec(@c1)
fetch next from c1 into @c1
endclose
c1deallocate c1

 

SQLServer 删除所有表的外键约束,布布扣,bubuko.com

热门排行

今日推荐

热门手游