Question

I am new to SQL Server Report Builder 2.0 and I need to compare two different databases in one query. Basically I need to check if values from one database table exist in a different database's table.

I know I can add multiple Datasources to my report and access each one with Subreports, but each DataSet that I create can only have one query in it. So how can I go about using one query to access two databases?

Or if there is another way to somehow join my results from multiple DataSets, that would work too.

Also, the databases are on the same server.

Was it helpful?

Solution

Point your DataSource at your master table on the server instead of pointing it at the specific database you want to pull from. As a result you will have to refer to all tables as < DBName >.dbo.< TableName >.< ColumnName >

OTHER TIPS

If the databases are on the same server you could do one query to a stored procedure, and then the proc accesses the 2nd database.

So in your report you would still use one datasource, and execute one stored proc, but then when the query runs on the database it handles the select / join whatever from the 2nd database.

By doing it this way you can return one dataset with the merged results if this is what you need to do. I will caution that cross database joins / selects etc can be considered bad practice for maintainability and the fact that if you decide to restructure your deployment to a multi server setup your joins wont work if the databases are not on the same server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top