SQLTeam.com | Weblogs | Forums

How to Add Constraint Default in SQL, Alter Table Command only

sql2008r2

#1

--Which one is Correct
--Source From W3SCHOOL
--This wasn't Working Error near key word SET
ALTER TABLE Leave
ALTER COLUMN EmployeeLeave SET DEFAULT 'Sick Leave'


#2

Try this:

 ALTER TABLE Leave
    ADD CONSTRAINT DF_EmpLeave DEFAULT 'Sick Leave' FOR EmployeeLeave;

DF_EmpLeave is the name of the constraint.So, you can use what name you like.