Reputation: 103
I have 2 columns in a table -
[SendDate] and [PayDate]
I am trying to implement a constraint that will check that - the product cannot be paid for if it has not been sent out.
I am not sure how to go on about it.
Any suggestions much appreciated, thanks
Upvotes: 3
Views: 57
Reputation: 44581
You can try something like this:
CHECK(
(SendDate IS NULL AND PayDate IS NULL) OR
(SendDate IS NOT NULL AND PayDate IS NULL) OR
(SendDate IS NOT NULL AND PayDate > SendDate)
);"
i.e. :
Upvotes: 2