Wednesday, August 26, 2015

alter column with default value in sql server

Alter column with default value in sql server Or 

Alter column with default constraint in sql server

Syntax: 
ALTER TABLE {TABLENAME} 
ADD {COLUMNNAME} {TYPE} {NULL| NOT NULL} 
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
[WITH VALUES]
Example:
ALTER TABLE EmployeeMaster
ADD City NOT NULL
CONSTRAINT EmpMaster_City DEFAULT 'Pune'

No comments:

Post a Comment