I have a table with the columns CompaniesId
and HotelsId
. I want to write a check constraint that confirms that one of these columns is null and other one is not.
I tried the following expression:
(CompaniesId is null) <> (HotelsId is null)
When I attempt to save this in the Check Constraints dialog box in SSMS, I get the helpful message:
Error validating constraint 'CK_CostingLineItemVendors'.
Could someone help me with my syntax?
EDIT:
According to the article IS [NOT] NULL (Transact-SQL), the result of IS NULL
or IS NOT NULL
is Boolean
. That's why I would assume I could compare these results for equality.