accessing tables from 2 different databases

  • hello there,

    i want to access two different tables a and b which are in two different databases d1 and d2 is there any way out

    thanks keyur

  • Just fully qualify the names, like this:

    select a.id, b.id from db1.dbo.test a inner join db2.dbo.test b on a.id=b.id

    If you set up a linked server, you can even do this across servers by using four part syntax:

    select a.id, b.id from db1.dbo.test a inner join DifferentServer.db2.dbo.test b on a.id=b.id

    Andy

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply