Hi!
This is a duplicate of my posting over on MSDN SSRS forum. Perhaps someone
here has seen this.
I hope that Microsoft can weigh in on this one:
I have a sql statement as part of a report that I'm developing using VS2005
and SSRS. The WHERE clause (part of a much larger SELECT / UNION initially
is:
WHERE (s.cnt = 51)
AND (fi.FI_Status = 0)
AND (fe.FE_Status = 0)
AND (fi.FI_Customer IN (@Customers))
AND (fi.LOB_INSTECSpecificCodeNumber IN (@LOBs))
I'm adding "All" support so I'm modifying it to:
WHERE (s.cnt = 51)
AND (fi.FI_Status = 0)
AND (fe.FE_Status = 0)
AND (fi.FI_Customer IN (@Customers) OR 'All' IN (@Customers))
AND (fi.LOB_INSTECSpecificCodeNumber IN (@LOBs) OR 'All' IN (@Customers))
On pressing the "!" button to test the query the designer is changing my sql
to:
WHERE (s.cnt = 51) AND (fi.FI_Status = 0) AND (fe.FE_Status = 0) AND
(fi.FI_Customer IN (@Customers)) AND
(fi.LOB_INSTECSpecificCodeNumber IN (@LOBs)) OR
(s.cnt = 51) AND (fi.FI_Status = 0) AND (fe.FE_Status
= 0) AND (fi.LOB_INSTECSpecificCodeNumber IN (@LOBs)) AND ('All' IN
(@Customers)) OR
(s.cnt = 51) AND (fi.FI_Status = 0) AND (fe.FE_Status
= 0) AND (fi.FI_Customer IN (@Customers)) AND ('All' IN (@Customers)) OR
(s.cnt = 51) AND (fi.FI_Status = 0) AND (fe.FE_Status
= 0) AND ('All' IN (@Customers)) AND ('All' IN (@Customers))
Note the removal of my parentheses, the repetition of logic and placement of
the ORs.
I've verified that both versions produce the same results but why is it
being changed? Perhaps the designer thinks that its version is optimized but
I (or others here) have to maintain it and my version (at least in my humble
opinion) is more readable as to the intent.
Please Microsoft share your thoughts on this "feature"??? Is there any way
to prevent it?
Thanks!
Glenn L