To join tables from two different databases, we can use fully qualified names of the tables in this format [databasename].[owner].[tablename].
SELECT ac.AutoId, ac.FullName, pd.Age
FROM [IHaveBeenRenamed].[dbo].Accounts ac
INNER JOIN
[SqlHowTo].[dbo].PersonalDetails pd ON ac.AutoId = pd.PersonalDetailsId
In the above query, we are joining Accounts table of IHaveBeenRenamed
database table and PersonalDetails of SqlHowTo
table on AutoId of Accounts table and PersonalDetailsId of PersonalDetails table.
To know how to join two databases that are physically on different servers, read this post of DotNetFunda.com -
Views: 19456 | Post Order: 62