Groups | Blog | Home
all groups > sql server reporting services > february 2007 >

sql server reporting services : Why is reporting services designer modifying my sql statement???


glennl
2/6/2007 5:56:00 AM
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

glennl
2/6/2007 7:47:00 AM
Thanks for the reply Bruce.

I was using the non-graphical one...I was entering pure sql.

Glenn L

[quoted text, click to view]
glennl
2/6/2007 8:30:02 AM
You're right...the problem did turn out to be the "non-generic" query
designer...I was entering the sql into the sql pane of what turned out to the
the "non-generic"one although it wasn't obvious (to me anyway). I found the
toolbar button that took me to the generic one and it didn't modify the sql.
Very subtle.

Thanks for the help!


GlennL

[quoted text, click to view]
Bruce L-C [MVP]
2/6/2007 9:24:26 AM
There are two designers. Graphical and non-graphical. I always use the
non-graphical because I typically am both faster and also write more complex
queries that I don't want munged up. The button to switch the type of query
tool to be using is to the right of the ...

Just hover over the buttons until you find the right one.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

Bruce L-C [MVP]
2/6/2007 10:08:40 AM
I don't think you are in the non-graphical. I live in it designer, it never
ever touches your SQL. The generic query designer (what they call the
non-graphical) is there exactly for this reason. Try toggling back and
forth.

One other point, are you using the Report Designer or are you using the
tools that come with VS and creating a local report?


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

AddThis Social Bookmark Button