Query tables in another database

   i have connected to database X. from this connection i would like to access tables in another database. purpose is to join tables in different database.

Who is Participating?
Maciej PileckiDatabase ArchitectCommented:
Best way is to use the Enterprise Manager. Linked servers are in Security branch. If your other server is SQL Server as well, it is fairly easy to set up it as linked server.
Maciej PileckiDatabase ArchitectCommented:
If the databases are on the same server you can just use the syntax:
to query the table residing in another db.

If the database are on the separate servers, you have to set up one server as linked server on the other (this can but does not have to be bi-directional link), and then use the syntax:

mohanraoAuthor Commented:
yes, it is two different servers. how can i do this "Linked server setup"
Go to enterprise manager

under security - you will see linked servers

right click on linked server
click on ne linked server
dialog box will open up
in linked server - type the name of the server you want to link
click on security tab
click radio button - they will be mapped to

this is for the remote server
remote user - username

at the bottom

login name - enter login name - example sa
remote user - enter username - example sa
when it has successfully created a link
you will see the name of the server
under that you will see tables - nothing else

when you need to query the database from query


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.