Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Deploy does not detect check constraint changes Expand / Collapse
Author
Message
Posted Tuesday, June 12, 2012 2:13 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, April 01, 2014 2:50 AM
Points: 1,419, Visits: 439
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?
Post #1314261
Posted Tuesday, June 12, 2012 6:30 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, April 01, 2014 2:50 AM
Points: 1,419, Visits: 439
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
Post #1314384
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse