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
 General SQL Server Forums
 New to SQL Server Programming
 How to access table in different database?

Author  Topic 

dsathishcse
Starting Member

3 Posts

Posted - 2008-04-29 : 02:13:10
Hi,
I have 2 databases in SQL Server named Database1 and Database2. I have logged in Database1. I would like to see the records of the Table which is present in Database2. Could anyone please tell me How to access the tables in Database2 from Database1?


Thanks,
Sathish kumar D

Sathish kumar D

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-29 : 02:47:16
If the two databases are in same server you can access it by
select * from database.schema.table

And if they are in different servers then:-
Either add secod server as a linked server and use four part naming as select * from server.db.schema.table
or uuse OPENDATASOURCE or OPENROWSET methods.
Go to Top of Page
   

- Advertisement -