We have been trying out SQL server reporting services. We are using SQL 2008 and Visual Studio 2008.
I Have a couple of linked reports, along the lines of
Report1: Summary of tickets that are still open past the date that they should have closed. Click through on a line to:
Report2: Details of a ticket and it’s dependant history data.
We have about ten databases, one for each client, with names like “TicketsDatabase_ClientA
” “TicketsDatabase_BCustomer
”.
I have deployed these reports to a SSRS server for internal review and testing, using “TicketsDatabase_ClientA
” as the DB on the data source.
Table structures on all the databases are the same. there are other databases as well, including one that can provide us with a list of client databases,
But I’d like to roll them out for all clients’ data. What is the simplest way to deploy these reports so that we can look at all customers’ data? Ideally the report would start with a drop-down to select customer by name and then proceed on the appropriate database.
If this is not possible, I’d settle for a page that lists customers. It looked like we could upload multiple copies of Report1, and just put a different connection string on each one. But Report1 connects to the linked report Report2 by name, so I’d need multiple copies of Report2, each with a different name, and multiple edited copies of Report1, each edited to link to a different version of Report2.
This is looking like a really unpalatable, lengthy manual process that will need to be repeated whenever there’s a new report or a new customer. Is there a way to choose the connection to use for a set of reports? What is best practice with this kind of case?
Update:
We have ended up with dynamic SQL - The reports have a Parameter bound to a dataset to select the database, and the main dataset using an SQL exec statement, e.g.
declare @dbName varchar(64)
SET @dbName =
(SELECT 'TicketsDatabase_' + db.[Name]
FROM MainDb.dbo.Clients db (nolock)
WHERE db.Id = @clientId)
EXECUTE ('USE ' + @dbName + '
SELECT Datatable.*
FROM ...
WHERE ...')