locked
SQL Server Database Constraints Order RRS feed

  • Question

  • Hello everyone,

    I have an issue with some SQL Server 2017 database constraints. There are two constraints of the same type that are violated at the same time.

    Let's have the following table with data:

    | Id | Type | Payload        |

    | 1  | T1    | {"Rol": "R1"}|

    | 2  | T1    | {"Rol": "R2"}|

    One of these constrains is checking about a maximum 2 rows allowed for a certain type. Hence, in the above case if we're trying to add a new row with Type: T1 this constraint will be violated.

    The other one is helping me to have only one entity with a certain rol, so if we're trying to add a new row with Type: T1 and Payload: {"Rol" : "R1" } this constraint will be violated, but also the one with max 2 rows allowed.

    Is there any mechanism that I can rely on in order to control which one will checked first?

    Wednesday, August 8, 2018 7:31 AM

Answers

All replies