Update Default Value of Column in SQL Server

This blog defines how to update default value of column in SQL Server.

--How to update Default Value of column in SQl Server
--Suppose I have added Column 'Status' in Employee Table
--And I want to give a default value so Normally we do as following:
--alter table Employee add default 'Active' for Status
--Note: The disadvantage of doing this is, we will be unable to change our Default value of Status in Future.

--If I am doing like this:

--alter table employee add constraint [default_Constraint_status] default 'Active' for status
--So when you want to update /change your default in status column so do following action:

--First drop you constraint Name
--eg. alter table employee drop constraint [default_Constraint_status]

--And then write
--alter table employee add constraint [default_Constraint_status] default 'Inactive' for status

 
Ebook Download
View all
Learn
View all