Check constraint. Boolean unqiue value check.

  • I'm trying to figure out the best way make sure that there is only one "active" row in a table at one time.

    CREATE TABLE Test (

    ID Int,

    AmountMin int,

    AmountMax int,

    isActive bit )

    Data in table.

    ID AmountMin AmountMax isActive

    1 100 200 0

    2 100 300 1

    3 200 550 0

    4 300 700 0

    How would I be able to make sure there's only one isActive true flag at any given time.

    Thanks.

  • Hi,

    have a look at this article MSDN

    There you'll find an example how to use a check constraint with a function.

    I hope this helps 🙂

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply