IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tbTable01_tbTable02]') AND parent_object_id = OBJECT_ID(N'[dbo].[tbTable01]'))
ALTER TABLE dbo.tbTable01
DROP CONSTRAINT FK_tbTable01_tbTable02;
GO
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tbTable01_tbTable02]') AND parent_object_id = OBJECT_ID(N'[dbo].[tbTable01]'))
ALTER TABLE dbo.tbTable01
DROP CONSTRAINT FK_tbTable01_tbTable02;
GO
Comments