How to set the DB as parameter in SSRS?
-
11-10-2019 - |
Question
I'm using ReportBuilder 3.0 for creating report in reporting services 2008. I have many DB with the same tables (different data) and I created a report that can be applied to all these DB. I want to add a parameter to choose the database so the user can choose the DB from which getting the data. I created a parameter (named "DB") with the name of the DBs as avilable values, but I can't use the parameter in the queries as I was expected:
SELECT *
FROM @DB.[dbo].[TableName]
That query (used in a dataset) doesn't work.
There's a way to set the DB as a parameter?
Solution
In TSQL, you would use dynamic sql to do this (EXEC(@CMD)). I doubt report builder will allow you to do this. There are security risks to this.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow