Add a SQL XOR Constraint between two nullable FK's

前端 未结 3 988
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 00:43

I\'d like to define a constraint between two nullable FK\'s in a table where if one is null the other needs a value, but both can\'t be null and both can\'t have values. Log

3条回答
  •  萌比男神i
    2020-12-19 00:55

    Alternate way is to define this check constraint in a procedure. Before you insert a record in the derived table, the constraint should be satisfied. Else insert fails or returns an error.

提交回复
热议问题