SQL Server allows you to combine tables from different databases if these databases are on the same server. The syntax of the connection is the same; the only difference is that you must specify the full table names.
Suppose you have two databases on the same server - Db1 and Db2 . Db1 has a table named Clients with a ClientId column and Db2 has a table called Messages with a ClientId column (let's not understand why these tables are in different databases).
Now, to join the above tables, you will use this query:
select * from Db1.dbo.Clients c join Db2.dbo.Messages m on c.ClientId = m.ClientId
RePierre Jul 11 2018-12-12T00: 00Z
source share