How to Add a column with a DEFAULT value to an existing table in SQL Sever

All topics about programming / development in T-SQL or other languages for SQL Server.
Post Reply
FredRad
Posts: 1
Joined: Tue Jul 16, 2019 4:04 pm

Tue Jul 16, 2019 4:06 pm

Can you add a column with a DEFAULT value to an existing table in SQL Sever?
sgfive
Posts: 14
Joined: Sat Jun 22, 2019 7:04 pm

Tue Jul 16, 2019 4:39 pm

The syntax for adding a column with a DEFAULT value to an existing table in SQL Sever can be seen below:

Code: Select all

ALTER TABLE {TABLENAME} 
ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} 
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
WITH VALUES
Post Reply

Social Media