Connecting Tech Pros Worldwide Help | Site Map

sql server queries

  #1  
Old August 17th, 2008, 06:55 PM
mo/-/sin
Guest
 
Posts: n/a
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.............
  #2  
Old August 17th, 2008, 08:35 PM
Dan Guzman
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server Queries to DB2 compatible buntyindia answers 1 November 15th, 2008 10:02 PM
Pass-through queries fail even after SQL Server reconnected marshmallowww@yahoo.com answers 5 June 27th, 2008 08:24 PM
How to protect my SQL Server queries Dino Buljubasic answers 2 November 21st, 2005 09:11 PM
Bad performance in queries with Jet4.0 and linked ODBC-tables to SQL-Server 2000 Andreas Lauffer answers 6 July 20th, 2005 02:32 AM