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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 RESTRICT ENTRIES 4 A COLUMN

Author  Topic 

Faraz Ahmed Qureshi
Starting Member

3 Posts

Posted - 2010-07-18 : 05:18:25
Hi all!

I want to restrict a column to accept only few entries while using SQL SERVER 2008. For instance, I want the column "LEVEL" of the table "USERS" to accept only one of the three choices, i.e. "BEGINNER", "INTERMEDIATE" OR "ADVANCED".

Sure would oblige if any of u experts would provide a complete syntax of SQL in this regard.

Thanx in advance,
Best Regards,
Faraz Ahmed Qureshi

malpashaa
Constraint Violating Yak Guru

264 Posts

Posted - 2010-07-18 : 05:54:18
Try this:

ALTER TABLE USERS ADD CONSTRAINT USERS_CHECK_Level
CHECK(Level IN ('BEGINNER', 'INTERMEDIATE', 'ADVANCED'));
Go to Top of Page

Faraz Ahmed Qureshi
Starting Member

3 Posts

Posted - 2010-07-18 : 11:15:42
THANX MAL!

XClent.

Faraz Ahmed Qureshi
Go to Top of Page
   

- Advertisement -