Deploy does not detect check constraint changes

  • I am using SQL Server database project in VS 2010, and am experiencing a weird behavior related to check constraints.

    I have a table, with 3 columns. For simplicity lets call them column_1, column_2 and column_3.

    Then I have a check constraint like this:

    ALTER TABLE [dbo].[Table1] ADD CONSTRAINT [CheckConstraint1]

    CHECK (column_1 is not null and column_2 is not null or column_1 is not null and column_3 is not null)

    Deploy to database, and everything looks good.

    Then I change the constraint by adding some parentheses to this:

    ALTER TABLE [dbo].[Table1] ADD CONSTRAINT [CheckConstraint1]

    CHECK ((column_1 is not null and column_2 is not null) or (column_1 is not null and column_3 is not null))

    This is obviously quite a different check constraint, but deploy does not seem to catch this change.

    Anyone got any suggestions?

  • Ok, so I forgot that OR and AND have different operator precedence, so the two constraints are effectively the same.

    Since I usually always put parentheses for readability - this slipped my mind :hehe:

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

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