0

I have a report where the WHERE clause is determined by a parameter @param.

SELECT SOMESTUFF FROM SOMETABLE WHERE thing = @param

I've added values to the parameter so at runtime, the user decides what to run the report for from a drop down box. I want to make an option to run it for all the values I defined as well. I haven't been able to figure out the code to make this happen.

So if I've given values A, B, C to the parameter, how do I tell it to do all of them in the expression?

d90
  • 767
  • 2
  • 10
  • 28
  • 1
    Possible duplicate of http://stackoverflow.com/questions/14893789/ssrs-how-to-add-all-option-to-ssrs-dropdown-filter/ – Ian Preston Oct 18 '13 at 14:50
  • @IanPreston I did read that and I am doing a multi value parameter. I'm specifically trying to see how to pass sql from the expression using a parameter. – d90 Oct 18 '13 at 14:54

1 Answers1

0

This really depends on the nature of the query, datatypes etc.

Assuming the 'thing' in your example is a int and your parameters are a comma separated list of int values you could use an IN clause in your query.

SELECT SOMESTUFF FROM SOMETABLE WHERE thing IN (@param)

Though in reality this would need to be an expression in SSRS

="SELECT SOMESTUFF FROM SOMETABLE WHERE THING IN (" + @param.Value + ")"

Seems from your example they may be strings (A,B,C) in which case you would need to put a single quote around each for this to work.

keithwarren7
  • 14,094
  • 8
  • 53
  • 74
  • The thing is text. I'm trying to basically run a query in my report to look for laptops, desktops, servers for an inventory report. I was hoping to use the parameter to change the where clause in my dataset to be either one of those or all of them. I was thinking of making the parameter looks like 'Desktops' OR thing='Laptops' OR thing = 'Servers' but that doesnt work. – d90 Oct 18 '13 at 17:36