What is the difference between a column with a default and a column with a default constraint?

The default value for a column can be added as follows:

ALTER TABLE [MyTable] ADD DEFAULT ((0)) FOR [MyColumn] 

or how is it

 ALTER TABLE [MyTable] ADD CONSTRAINT [DF_MyTable_MyColumn] DEFAULT ((0)) FOR [MyColumn] 

What is the difference between the two?

+7
source share
2 answers

The restriction in the first example will be named SQL Server.

+8
source

SQL Server especially classifies defaults as "constraints." The syntax using the CONSTRAINT keyword allows you to specify a default name, which is good practice.

+4
source

All Articles