开发者

how to give a check constraint to a character coloumn

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 in开发者_Go百科to sqlserver2005 while creating a table,, in which group is a column...

Thanks, Churchill


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')))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜