declare @string varchar(8000)
while exists(select name from sysobjects where xtype='c')
begin
select top 1 @string='alter table ['+b.name+'] drop constraint '+a.name
from (select parent_obj,name from sysobjects where xtype='c') a,
(select id,name from sysobjects where objectproperty(id, N'IsUserTable') = 1) b
where a.parent_obj=b.id
exec(@string)
print @string
end
浙公网安备 33010602011771号