Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 cross database query?

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2012-04-18 : 11:00:36
Hi friends

I have a single server: General
and it has two databases Customer , Agents

Each database has its own credentials for accessing them..

But now i want to join two tables in each of these databases..

How can i do them...

Thank you in advance

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-04-18 : 11:42:37
use the 4 part naming convention

[server].[database].[schema].[table]

So if the db's are on the server then you can access the tables by [database].[schema].[table] (by default objects live in the dbo schema

SELECT * FROM db1.dbo.table1


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-19 : 00:59:11
hope your credential has same access priviledges in both dbs

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -