I want to know what is CHECK constraint in SQL server .
Thank you.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Akkiraju IvaturiPosted Aug 5, 2012, 3:06 AM
Satyapriya NayakPosted Jul 31, 2012, 9:08 AM
CHECK Constraint
The CHECK constraint is used to limit the value range that can be placed in a column.
If you define a CHECK constraint on a single column it allows only certain values for this column.
If you define a CHECK constraint on a table it can limit the values in certain columns based on values in other columns in the row.
SQL CHECK Constraint on CREATE TABLE
The following SQL creates a CHECK constraint on the "P_Id" column when the "Persons" table is created. The CHECK constraint specifies that the column "P_Id" must only include integers greater than 0.
CREATE TABLE Persons
(
P_Id int NOT NULL CHECK (P_Id>0),
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
Please refer the below links
http://www.w3schools.com/sql/sql_check.asp
http://msdn.microsoft.com/en-us/library/ms188258%28v=sql.105%29.aspx
http://www.databasejournal.com/features/mssql/article.php/3811831/Using-Check-Constraints-to-Validate-Data-in-SQL-Server.htm
Thanks
Sivaraman DhamodaranPosted Jul 31, 2012, 7:55 AM
Refer the Link: DB Constraints
Naresh AvariPosted Jul 31, 2012, 5:57 AM
Refer this:
http://msdn.microsoft.com/en-us/library/ms188258(v=sql.105).aspx