![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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............. |
|
|||
|
Re: sql server queries
> 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............. 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.com> wrote in message news:27e85557-d026-4669-8a03-07be4b94a1e0@a8g2000prf.googlegroups.com... > 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............. |
|
|||
|
Re: sql server queries
>> there is a column name gender and i want that it should accept only two values either 'male' or 'female'... <<
1) Google the ISO sex code Standard; there is more to the sex_code than just two values. If you ever take one of my database design classes, you will learn about missing and N/A values as part of schema design. 2) Use a CHECK() constraint. Looking at your postings, you have not done any studying and are trying to get your homework done on Newsgroups. |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|