Add Column in Table with Default Value in SQL Server

 1. First Add Column In Table With Default Value Along With Constraint Name
 
 ALTER TABLE Table_Name ADD Column_Name INT CONSTRAINT default_deleted DEFAULT(1)
 
 NOTE : Now If You Insert Any Value In Your Table Except New Column Then Default Value 1 Will Insert Into New Column
 
 2. If You Want To Drop Column Having Default Value, Then You Will Have To Drop Default Constraint
 
 ALTER TABLE Table_Name DROP CONSTRAINT default_deleted
 
 3. After Deleting Default Constraint, You Can Drop Column
 
 ALTER TABLE Table_Name DROP COLUMN Column_Name
Ebook Download
View all
Learn
View all