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 |
|
sun89
Starting Member
3 Posts |
Posted - 2009-09-08 : 14:28:45
|
| in my table , in the "class" attribute i want strings inserted to be either 'gold' or 'silver' ... how can i put that in check constraint? ... plz help!!! |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-09-08 : 15:03:33
|
| You need to have a CHECK contraint on that column...something like CHECK (class IN ('gold', 'silver'))check BOL for further examples. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-09-08 : 15:05:57
|
| CREATE TABLE myTable(class varchar(6) NOT NULL CHECK (class IN('gold','silver')))orALTER TABLE myTable ADD CONSTRAINT chk_class CHECK (class IN('gold','silver')) |
 |
|
|
sun89
Starting Member
3 Posts |
Posted - 2009-09-08 : 15:16:20
|
| Thanks a lot :) |
 |
|
|
|
|
|