Connecting Tech Pros Worldwide Help | Site Map

sql server queries

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 17th, 2008, 05:55 PM
mo/-/sin
Guest
 
Posts: n/a
Default sql server queries

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, 07:35 PM
Dan Guzman
Guest
 
Posts: n/a
Default 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.............
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.