Ever since loading SP2, we've noticed that we are getting different results in some of our queries. For example, the following query:
SELECT *
FROM [dbo].[vwr_pr152w1]
WHERE ([dbo].[vwr_pr152w1].[ycurramt] <> 0.000 OR [dbo].[vwr_pr152w1].[ycurrhrs] <> 0.000)
AND [dbo].[vwr_pr152w1].[cemptype] <> 'I'
or ([dbo].[vwr_pr152w1].[ccalcflag] = 'X' OR [dbo].[vwr_pr152w1].[ccalcflag] = 'E')
AND [dbo].[vwr_pr152w1].[HR180ID] = 15
--The above query produces very different results than
SELECT *
FROM [dbo].[vwr_pr152w1]
WHERE ([dbo].[vwr_pr152w1].[ycurramt] <> 0.000 OR [dbo].[vwr_pr152w1].[ycurrhrs] <> 0.000)
AND [dbo].[vwr_pr152w1].[cemptype] <> 'I'
AND [dbo].[vwr_pr152w1].[HR180ID] = 15
or ([dbo].[vwr_pr152w1].[ccalcflag] = 'X' OR [dbo].[vwr_pr152w1].[ccalcflag] = 'E')
ALL I did was move the hr180id = 15 line BEFORE the ccalcflag line. The bottom produces the correct output of 1 employee.
There are no employees with ccalcflag x or e so the or should bring back anything anyway,
but if you run the first query, it brings back every employee in the database.
What changed in SP2 to create this behavior?
Thanks...
Scott Klein
Author - Professional SQL Server 2005 XML
http://www.wrox.com/WileyCDA/WroxTit...764597922.html