Thursday, December 13, 2012

SQL: Set Default Value for a Column

Below is the structure for setting the default value for a column.  You will not face NULL values in the columns where this constraint gets added.

ALTER TABLE TableName
ADD CONSTRAINT
ADDED DEFAULT DefaultValue FOR ColumnName

Now lets apply it with a table so you will get more idea of how to work with it.


ALTER TABLE Student
ADD CONSTRAINT
ADDED DEFAULT 0 FOR IsAdded

Hope you have got the idea.

No comments:

Post a Comment