Skip to content
Advertisement

Both columns can’t have nulls at the same time, only one per time, how to define this constraint?

I have a table:

If clients feedback than 1 otherwise Barbers feedback 1, how to make a constraint for this situation?

  • ClientFeedback bit null,
  • BarberFeedback bit null,

Sorry for English

Advertisement

Answer

You use a check constraint. For instance, if you want exactly one value to be 1:

I am guessing that might be what you want. But your question is specifically about NULL values. That constraint would be:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement