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
 Create a column that must have either of 2 values

Author  Topic 

scvinod
Starting Member

16 Posts

Posted - 2009-08-02 : 10:09:32
Hi All,

I have to create a column which must have only X or Y.Can anyone help me out please.Thanks in advance.

scv

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-02 : 11:00:31
see CHECK CONSTRAINT in books online.

one way to add a constraint is:
alter table <yourTAble> add constraint <CH_myConstraint> CHECK (<myColumn> in ('X', 'Y'))

Be One with the Optimizer
TG
Go to Top of Page

scvinod
Starting Member

16 Posts

Posted - 2009-08-02 : 11:32:54
Thanks dude....tht helped me a lots :)

scv
Go to Top of Page
   

- Advertisement -