Different Query results since loading SP2

Last Post 22 Mar 2007 12:09 PM by SQLScott. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
SQLScott
New Member
New Member

--
22 Mar 2007 07:32 AM
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...
SQLScott
New Member
New Member

--
22 Mar 2007 12:09 PM
Yeah, after posting that I started looking at it in that sense and slapped myself upside the head for not properly using parenthesis.

Thanks russell
You are not authorized to post a reply.

Acceptable Use Policy