删除用reference建立的外键
由于用reference建立的外键名字不确定,故用以下方法:
DECLARE @name VARCHAR(100)
SELECT @name =NAME FROM dbo.sysobjects where name like 'FK__Card_Cust__CardN__%'
and OBJECTPROPERTY(id, N'IsForeignKey') = 1
exec('Alter Table Card_CustomerCardDetail
Drop CONSTRAINT '+ @name)
DECLARE @name VARCHAR(100)
SELECT @name =NAME FROM dbo.sysobjects where name like 'FK__Card_Cust__CardN__%'
and OBJECTPROPERTY(id, N'IsForeignKey') = 1
exec('Alter Table Card_CustomerCardDetail
Drop CONSTRAINT '+ @name)