Why does SQL Server keep creating a DF constraint?

This is the default constraint that is added because of the DEFAULT(0) in your newly added column.

You can name this yourself so it has a known fixed name rather than relying on the auto name generation.

ALTER TABLE TableName
    ADD ColumnName bit NOT NULL CONSTRAINT DF_Some_Fixed_Name DEFAULT(0) 

Then to remove the column and constraint together

ALTER TABLE dbo.TableName
DROP CONSTRAINT DF_Some_Fixed_Name, COLUMN ColumnName

Leave a Comment