Sunday, February 12, 2012

Constraint

I have a varchar field in a table.I want to restrict the entries in that field as "yes" or "no" nothing else.No record will be allowed for this field without yes or no.My question is is it possible without using any trigger for the table?I want to do it with the help of a constraint.I think a check constraint could work for you, for example: create table tab (field1 varchar(3) constraint ck_yesno check (field1 in ('yes', 'no')), field2 int).

No comments:

Post a Comment