SSRS - Connect to two different databases in one SQL possible?

  • It doesn't appear by looking at the DataSets where you specify a Data Source that you can select from two data sources in one sql? Or is it possible and if yes how?

    I need to be able to select from two different databases. es.

    select a.name, b.email
    from database1.table1 a, database2.table2 b
    where a.emplid = b.emplid
    etc.

  • If you add the Server not in the Data Source to the linked Servers on the Server configured in the Data Source, you can access it like any other linked server.

  • If you're writing the query in the actual report, then you can try DinoRS's solution, and have it in the query results, which will be faster.

    But if for some reason you can't do that, then you can create a new datasource, point a different dataset to it with a key column that allows you to do a Lookup into your first datasource.
    https://www.sqlservercentral.com/Forums/Topic1810828-150-1.aspx

    -------------------------------------------------------------------------------------------------------------------------------------
    Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses

  • DinoRS - Monday, September 17, 2018 10:03 AM

    If you add the Server not in the Data Source to the linked Servers on the Server configured in the Data Source, you can access it like any other linked server.

    How do you do that?

  • Well the basic idea is this: you have ServerA as your Data Source configured, you create a linked Server connection on ServerA to ServerB. If you need to access Data from Server B now you would do a Select ServerB.Database.Schema.Table on ServerA, so any queries involving those 2 Servers need to be changed accordingly.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply