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
Last modified: April 29, 2022

Author

Comments

Write a Reply or Comment