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 2008 Forums
 Transact-SQL (2008)
 Constraints with OR?

Author  Topic 

tech_1
Posting Yak Master

129 Posts

Posted - 2011-12-08 : 15:42:38
Is it possible to have a constraint of some kind where:

Either ID must be populated OR
2 other fields must be populated
BUT all 3 fields cannot have values populated together

thanks

tech_1
Posting Yak Master

129 Posts

Posted - 2011-12-08 : 16:11:16
([ID] IS NULL AND [Field1] IS NOT NULL AND [Field2] IS NOT NULL OR [ID] IS NOT NULL AND [Field1] IS NULL AND [Field2] IS NULL)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-09 : 00:27:43
put a check constraint on table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -