Is it possible to change a query in Reporting Services based on a parameter?
I’d like to be able to change table names within the query from tableName to tableName2 (for example) on the fly.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are two ways you could do it:
For 1, you’d do something like this:
For 2, you’d do something like this:
WARNING: Be very careful of option 2. If option 1 is feasible, then it is the safer option, as dynamically constructing SQL based upon user-supplied values is always a dangerous affair. While this particular example doesn’t use the parameter directly in the SQL, it would be very easy to write something that did, and thus very easy to find a way to exploit it.