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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naresh AvariRank #2,678 · 520 reputationPosted Jul 31, 2012, 1:57 AM EDT
Refer this:
http://msdn.microsoft.com/en-us/library/ms188258(v=sql.105).aspx
Sivaraman DhamodaranRank #40 · 34.5K reputationPosted Jul 31, 2012, 3:55 AM EDT
Refer the Link: DB Constraints
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 31, 2012, 5:08 AM EDT
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
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Aug 4, 2012, 11:06 PM EDT