Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
johnk111
Starting Member
1 Post |
Posted - 2009-12-01 : 10:57:04
|
| Hi,I need to know, can we have a list of values that are acceptable in a certain field.E.gin the department column, I only want to accept the values Sales,Accounts,Warehouse or Admin.How would I do this?Thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-12-01 : 11:02:33
|
If "Field" in your world is a Column in a table in sql server then you can!If "Field" is a field in your application then this is not the best forum for this question.Be a bit more clear please. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-12-01 : 11:08:24
|
Like webfred said..if its a column in a atble u need a CHECK constraint likeCONSTRAINT CK_department CHECK (department IN ('Sales','Accounts','Warehouse','Admin'))check BOL for more examples |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-12-01 : 11:14:39
|
quote: Originally posted by vijayisonly Like webfred said..if its a column in a atble u need a CHECK constraint likeCONSTRAINT CK_department CHECK (department IN ('Sales','Accounts','Warehouse','Admin'))check BOL for more examples
Or a foreign key to a table with valid values. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|