Are you looking to link two databases? ie use a query that acesses tables from other databases?
If so all you need to do is to use a fully qualified name to call your table from the other database
select * from [databaseName].dbo.[tableName]
If your other database is on another server first you will have to link the servers then
select * from [serverName].[databaseName].dbo.[tableName]
I hope this help you.