Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Reporting Services
»
Reporting Services 2008 Development
»
query with OR in where clause
query with OR in where clause
Rate Topic
Display Mode
Topic Options
Author
Message
masqazi
masqazi
Posted Saturday, September 18, 2010 2:15 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, February 27, 2013 2:48 AM
Points: 14,
Visits: 26
i have a query
select name, name2, type, date, status from table1
where (name = '' or name <>name2) and status =0
but, ssrs is converting this query automatically to
select name, name2, type, date, status from table1
where name = '' and status =0 or name <>name2 and status =0
this is giving wrong results... the reason is brackets are missing in operands..the correct way could be
select name, name2, type, date, status from table1
where (name = '' and status =0 ) or (name <>name2 and status =0)
how to solve this ??
Post #988702
Grant Fritchey
Grant Fritchey
Posted Monday, September 20, 2010 9:09 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 3:55 AM
Points: 13,381,
Visits: 25,165
What about making it into a stored procedure and then making the call to that? That would absolutely fix the issue.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #989470
masqazi
masqazi
Posted Tuesday, September 21, 2010 12:30 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, February 27, 2013 2:48 AM
Points: 14,
Visits: 26
stored procedures is an alternative...but i am concerned why query is doing this on its own..
even when i write is corretly and save...its saving its own way.
Post #989977
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.