How To Add A Default Constraint To An Existing Column Using T-SQL



TODO:

Have you ever wanted to update a column to have a default constraint?

 

SOLUTION:

ALTER TABLE MyTable ADD CONSTRAINT DF_MyTable_IsTest DEFAULT 0 FOR IsTest

 

NOTES:

The T-SQL above, will add a default constraint, that will default the column 'IsTest' to 0