databasesql-server-2005database-tools

How do I join two tables from two different databases?


Is there any way to use a query and join two tables that is in two different database on the same server for DbVisualizer? I used the following for the SQL server

Select * from table union select * from datbase.dbo.table2

I tried this for the DbVisualizer, and it didnt work. How do I do this?


Solution

  • If the databases are in different servers you need to make sure that they are set up as linked servers.

    Also be warned that the optimizer is relatively weak in this scenario, same server or not. The problem is that the statistics used for weighting costs of different operations aren't necessarily meaningful between different databases, especially at the point where the two databases will "intersect". So performance isn't what it could be.