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
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Constraint Help

Author  Topic 

HarryYee
Starting Member

4 Posts

Posted - 2001-10-11 : 12:42:41
I want to add a constraint where a certain column can not be set to a certain value if another column is not null.

So column1 can be values 0 - 11, however it can be 0 only if the value in column2 is null. I belive it would look similar to this.. am I on the right track?

ALTER TABLE tablename ADD CHECK((([column1] In (1,2,3,4,5,6,7,8,9,10,11)]) Or
([column1] = 0 And column2 Is Null)))
go

   

- Advertisement -