Data from 2 different data sources

  • I have same table on two different databases. Need to create a report to get data from both of these tables on different data bases.

    First, is this even possible? IF so, let me know

  • If both databases are on the same server, you just need to use a 3 part naming convention for your tables in the query.

    SELECT one.A, one.B, one.C, two.A, two.B, two.C

    FROM DatabaseName1.dbo.tableName AS one

    INNER JOIN DatabaseName2.dbo.tableName AS two

    ON one.A = two.A

    If they are different servers you will need to create a linked server on one of the servers and use a 4 part naming convention for the remote db.

    SELECT one.A, one.B, one.C, two.A, two.B, two.C

    FROM dbo.tableName AS one

    INNER JOIN LinkedServerName.DatabaseName2.dbo.tableName AS two

    ON one.A = two.A

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

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