December 23, 2009 at 4:54 am
Hi, Happy Christmas to you,
I am trying to set up a constraint that goes a bit like this
If column1 is not null then column2 cannot be null either.
Tried using constraint CHECK(column1 is not null and column2 is not null) this didnt work and does not have the if requirement.
Any help or sources of good examples on this would be great - should I go down the route of writing scalar functions and checking against this function?
Many Thanks for your help, Cheers,
Oliver
December 23, 2009 at 6:46 am
i've seen this requirement before:
check out the Check Constraint example i made here, aptly named "ThereCanBeOnlyOne"
http://www.sqlservercentral.com/Forums/Topic789104-145-1.aspx
it uses a check constraint to make sure zero or one of the columns has a value, raising an error if both; it would be trivial to change it so that ther emust be at elast one selection.
Lowell
December 23, 2009 at 6:53 am
Thanks i thought this might be the right way to go about it.
Much appreciated.
Oliver
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply