DEFAULT Constraint – Adding Column Defaulting in Sql Server Table

The DEFAULT constraint is used to insert a default value into a column.

The default value will be added to all new records, if no other value is specified.

Rather than providing a value into a column manually during insert operation, by using default option we can auto-populate specific value and update in column.

in the below example, no need to provide CreatedDate and Freezed values during Insertion .

Example :

create table TestTable
(
Id int IDENTITY(1,1) NOT NULL,
UserId int,

—–

—–
CreatedDate datetime default (getdate()),
Freezed int default (0)
)