Reputation: 81
How can i give a check constraint to a column whose datatype is char(1)
coloumn name--->group
datatype------->char(1)
CHECK(c,s,a)
plz tell me the exact query how to insert it into sqlserver2005 while creating a table,, in which group is a column...
Thanks, Churchill
Upvotes: 1
Views: 10163
Reputation: 24506
From your question, it seems as though you only want to allow the value c, s, or a. If I understand correctly....
Create Table YourTableNameHere(
Id Int,
col Char(1)
Constraint ConstraintNameHere Check(Col In ('c','s','a')))
Upvotes: 4