DECLARE @TABLE_NAME VARCHAR(255) DECLARE @col_name VARCHAR(255) DECLARE @command VARCHAR(1000) SET @TABLE_NAME = '$YOUR_TABLE_NAME' SET @column_name = '$YOUR_COLUMN_NAME' SELECT @command = 'ALTER TABLE ' + @TABLE_NAME + ' DROP CONSTRAINT ' + d.name FROM sys.tables t JOIN sys.default_constraints d ON d.parent_object_id = t.object_id JOIN sys.columns c ON c.object_id = t.object_id AND c.column_id = d.parent_column_id WHERE t.name = @TABLE_NAME AND c.name = @column_name EXECUTE (@command)
Add new comment