Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Joins

Posted on 2005-03-08
2
Medium Priority
?
260 Views
Last Modified: 2012-08-13
Can someone show me how too join from 2 different databases as opposed too 2 different tables in one database

The databases i want to join are dbo.tblfall_Details on database A to tblEnd_Details on Database B
The field i want to join is tblFall_Details.aby to tblEnd_Details.userID

Nb userid is a primary key, whereas aby isnt!

Thanks in advance
0
Comment
Question by:paulo111
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 1500 total points
ID: 13486239
Hi paulo111,

Select A.*, B.* From DatabaseA.dbo.tblFall_Details A Inner Join DatabaseB.dbo.tblEnd_Details B On A.aby=B.userID

Tim Cottee
0
 
LVL 7

Expert Comment

by:lozzamoore
ID: 13486436

The technique is the same regardless, simply add the database parameter to the four part object naming convention.

server.database.owner.name.

So you see, if you have set up linked servers, you can easily join tables on different servers in the same way!! (cool eh?)

One caveate when going across databases (or servers!) is that you could encounter collation issues, if the databases have different collations.

One way around this is to use the "collate database_default" directive right after each join expression.

Cheers,
0

Featured Post

Independent Software Vendors: 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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

564 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