Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Link tables in SQL Server

Posted on 2004-10-20
5
Medium Priority
?
213 Views
Last Modified: 2006-11-17
Ok, easy question.

How do you link tables in SQL Server?  That is, how do you access tables from other databases (on the same SQL Server)?
0
Comment
Question by:tristan256
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 34

Accepted Solution

by:
arbert earned 840 total points
ID: 12366645
If you want to access tables ON THE SAME SERVER in another database, just use the naming convention:

select * from databasename.owner.tablename

Of course, you need permissions in the other database....
0
 
LVL 34

Expert Comment

by:arbert
ID: 12366653
And if you wanted to join from the current database to tables in another database:

select * from currentdbtable t1 inner join otherdatabase.owner.tablename t2
on t1.key=t2.key
0
 

Author Comment

by:tristan256
ID: 12366726
aah, didn't know you had to specify the owner as well.

Cheers.
0
 
LVL 34

Expert Comment

by:arbert
ID: 12366832
Good deal.  Always a good habit to get into to always include the owner...
0
 

Expert Comment

by:bhavik
ID: 12411317
What do I have to do,  so that the table in database A is available to all databases (B, C,...) In a way that any queries done by connecting to n B and C looks like the table is in B and C.
I do not want to use the fully qualified name nor do I want to change my code to add openquery statements.

The situation is I'm using dotnet code to query two databases that where split out of one.









0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question