Link to home
Start Free TrialLog in
Avatar of paulo111
paulo111

asked on

Joins

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
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

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,