SSRS 2008 Dataset Query Command Text Error

Below Query Command Text runs fine in SSRS Dataset to retrieve records. It retrieves data from a function with parameters.

SELECT DISTINCT
SubRegion
FROM WKLD.fnGetOEDGETransReportData(@FromDate,@ToDate,@FromHr,@ToHr,@FromMin,@ToMin,@Office,@Desk,@Shift,null)
ORDER BY 1

Now,  what I am trying to do is add a Where Clause so the query looks like this.

SELECT DISTINCT
SubRegion
FROM WKLD.fnGetOEDGETransReportData(@FromDate,@ToDate,@FromHr,@ToHr,@FromMin,@ToMin,@Office,@Desk,@Shift,null)
Where ActivityName = "TOP"
ORDER BY 1


But, I get the below error.

Invalid column name 'TOP'.

How can I include a Where Clause in this query or can it not be done.
I do not want to change the function since I did not write it unless I have to.
Just want to change this Query Command Text in the SSRS Dataset to include Where Clause.
thayduckProgrammer AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

thayduckProgrammer AnalystAuthor Commented:
I figured out a way that works:

=IIF(Parameters!Office.Value <> "HOMEWOOD","SELECT DISTINCT SubRegion FROM WKLD.fnGetOEDGETransReportData(@FromDate,@ToDate,@FromHr,@ToHr,@FromMin,@ToMin,@Office,@Desk,@Shift,null) WHERE ActivityName IN ('TOP') ORDER BY 1","SELECT DISTINCT SubRegion FROM WKLD.fnGetOEDGETransReportData(@FromDate,@ToDate,@FromHr,@ToHr,@FromMin,@ToMin,@Office,@Desk,@Shift,null) WHERE ActivityName IN ('TA') ORDER BY 1" )

But curious why the other way does not work.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ManjuIT - Project ManagerCommented:
Top in your where clause should be in single quotes.

'Top'
0
thayduckProgrammer AnalystAuthor Commented:
I tried it that way and it still failed.
0
thayduckProgrammer AnalystAuthor Commented:
I am going to close this question since I have a work around.
0
thayduckProgrammer AnalystAuthor Commented:
I figured out how to get it to work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.