How to set a default value for an existing column in sql server

By | November 9, 2017

How to set a default value for an existing column in SQL server

Syntax: 
ALTER TABLE {TABLENAME} 
ADD {COLUMNNAME} {TYPE} {NULL| NOT NULL} 
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
[WITH VALUES]
For Example:

ALTER TABLE EmployeeMaster
ADD City NOT NULL
CONSTRAINT EmpMaster_City DEFAULT 'Pune'

Click here for more SQL Tutuorials

Leave a Reply

Your email address will not be published. Required fields are marked *