Two Different Servers JOIN (limited permissions)

  • I have permission to run queries on two different servers. If I need to preserve data I just send the query results to a text file. Sometime I use #temp files since I can create tables, databases, etc with my permissions.

    I need to do a simple join from two different #temp files (#ServerA and #ServerB) from the two different servers. I’m assuming this is obvious but I’m using Management Studio to access these servers on the same machine.

    Is there a way to join these two temp files since they are on different servers? Thanks!

  • If the servers are linked, you could do this easily, as in this example:

    SELECT FirstTable.* from ServerA...Table1 AS FirstTable

    INNER JOIN ServerB...Table2 AS SecondTable

    ON FirstTable.ID = SecondTable.ID

    However, assuming the servers are not linked & you have neither the permissions to do so nor your DBA's inclination to do this for you, you could also use another tool, like Excel. Add each server as a connection. You can then grab your data from both servers so you can store & manipulate it there.

    -Bob

    @SingingDBA

    http://www.SingingDBA.com

  • Joining tables across servers is generally a bad idea. It is EXTREMELY slow with more than just a handful of rows in the tables on each side.

    If you are on ServerA, then it's probably a better idea to copy just what you need from ServerB into a temp table on ServerA and use that in your join.

    Todd Fifield

Viewing 3 posts - 1 through 2 (of 2 total)

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