declare @sql varchar(max),
@tab_name varchar(128),
@fk_name varchar(128);
declare c cursor for
select OBJECT_NAME(f.parent_object_id), name
from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id
where f.parent_object_id=object_id('sa_UserMaster')


open c
fetch next from c into @tab_name, @fk_name
while @@FETCH_STATUS=0
begin
set @sql='';
set @sql='alter table ' + @tab_name + ' drop constraint ' + @fk_name
print @sql
exec(@sql)

fetch next from c into @tab_name, @fk_name
end
close c
deallocate c

相关文章:

  • 2021-07-14
  • 2021-08-19
  • 2021-10-25
  • 2021-07-17
  • 2021-12-16
猜你喜欢
  • 2021-09-04
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2021-08-16
  • 2021-05-28
  • 2022-02-03
相关资源
相似解决方案