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

--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'

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.

1 Like

Drop the problematic DEFAULT constraint first, then the problematic column.

alter table tbloffers drop constraint [ConstraintName]
go

alter table tbloffers drop column checkin

However, there are other potential causes of the problem, such as a user-defined function or view with the 'SCHEMABINDING' option enabled.