DECLARE
@ObjectName SYSNAME = '[NameOfDatabaseObject]';
IF OBJECT_ID(@ObjectName) IS NOT NULL
PRINT @ObjectName + ' database object exist in the database.'
ELSE
PRINT @ObjectName + ' database object does NOT exist in the database.'
IF (OBJECT_ID('dbo.FK_ConstraintName', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.TableName DROP CONSTRAINT FK_ConstraintName
END
Comments