Connecting Tech Pros Worldwide Forums | Help | Site Map

sql server queries

mo/-/sin
Guest
 
Posts: n/a
#1: Aug 17 '08
plz tell me that: suppose i want make a table in sql server 2005 and
there is a column name gender and i want that it should accept only
two values either 'male' or 'female'..... no other value except
these...... how can i do that..... i wil b thankful to u.............

Dan Guzman
Guest
 
Posts: n/a
#2: Aug 17 '08

re: sql server queries


there is a column name gender and i want that it should accept only
Quote:
two values either 'male' or 'female'..... no other value except
these...... how can i do that..... i wil b thankful to u.............
One method is with a check constraint:

ALTER TABLE dbo.People
ADD CONSTRAINT CK_People_Gender
CHECK (Gender IN('male', 'female'))


--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

"mo/-/sin" <Ri.mohsin@gmail.comwrote in message
news:27e85557-d026-4669-8a03-07be4b94a1e0@a8g2000prf.googlegroups.com...
Quote:
plz tell me that: suppose i want make a table in sql server 2005 and
there is a column name gender and i want that it should accept only
two values either 'male' or 'female'..... no other value except
these...... how can i do that..... i wil b thankful to u.............
Closed Thread