An old friend of mine today asked me a question that I thought I should go ahead and post. The question was; how do you run a join across databases. Do let’s say for example you would like results to be a combination of sales from the Employee database and the Sales database (so you want to know who the best sales person is), but they are in different databases.
Good question but depends on the version of SQL Server. All you have to do is hit it by the fully qualified name. So for an example. If you wanted to do this and both databases (Employee and Test1) are on the same server then you would do a join like this.
From Employees.dbo.Employees e
Join Sale.dbo.sales s on e.id =s.id
So really the answer is no matter what the version you have to use a fully qualified name. Here is the name pattern <LinkedServerName>.<DatabaseName>.<Owner>.<TABLE> now this is for SQL Server 2000 and older.
If you are working with SQL Server 2005 or newer then it changes to <LinkedServerName>.<DatabaseName>.<Scheme>.<TABLE>
There really is not a big difference here. Just remember if you normally when you write a SQL Statement the defaults of the database you are in and DBO as the owner are used. If you use one to the left of the Table name such as database name like this (Employees..Employees) I think it looks and reads the best if you still include the owner or the scheme.