Solved

Link tables in SQL Server

Posted on 2004-10-20
5
210 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 210 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

734 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