declare @a varchar(20)
select @a=c.name from syscolumns a,sysconstraints b,sysobjects c where a.id=object_id('表名') and a.name='主鍵列名' and a.id=b.id and b.constid=c.id and c.name like 'PK%'
if @a is not null
exec('alter table 表名 drop constraint '+@a)
select @a=c.name from syscolumns a,sysconstraints b,sysobjects c where a.id=object_id('表名') and a.name='主鍵列名' and a.id=b.id and b.constid=c.id and c.name like 'PK%'
if @a is not null
exec('alter table 表名 drop constraint '+@a)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货