Code Snippet posted by:
Abhisek | Posted on: 11/29/2009 | Category:
SQL Server Codes | Views: 712 | Status:
[Member]
|
Alert Moderator
The following syntax is used to add check to the table at the time of its creation.
CREATE TABLE<table_name> (col datatype, check(condition), col2 datatype,...)
More than one check constraints can be added to a single table. This will put a
limitation to the values of an specific domain.
Example:
create table student(name char(20), age int check(age<=20))
The above code will add a constraint to the student table at the time of its creation to restrict the age value to 20.
Abhisek Panda