October 7, 2009

Sql Server: set DEFAULT constraint value after table creation

DEFAULT CONSTRAINTS:
DEFAULT constraints allow you to specify a value that the database will use to populate fields that are left blank in the input source.

ALTER ATBLE [Table Name]
ADD CONSTRAINT [Constraint Name] DEFAULT [Default Value] FOR [Column Name]


Example:
Alter table tblabc
ADD CONSTRAINT c_default default getdate() for inDateTime

No comments:

Post a Comment