Cloud Training (Online)




SQL Server 101 – How to add a column with a default value to existing table ?

There are times when you want to add an column with a default value to the existing table in SQL Server and you can easily do that with the DEFAULT keyword.

How to add a column with a default value to existing table in SQL Server ?

Assume that you want to add a column called “EmploymentStatusID” to the “Employee” table with the default value of 1. Below is the code that demonstrates how to do it.

ALTER TABLE Employee
ADD EmploymentStatusID int NOT NULL DEFAULT(1)
GO