locked
Query 2 different databases and tables RRS feed

  • Question

  • I have two databases and I want to do a join between 2 tables, 1 in each database. How would I accomplish this?
    Wednesday, October 12, 2011 5:49 PM

Answers

  • Select MainQry.*, SubQry.*

    From Database1.dbo.table1 As MainQry Inner Join Database2.dbo.Table2 As SubQry On MainQry.PK = SubQry.PK

     

    Check INNER JOIN in BOL.


    Best Wishes, Arbi --- MCC 2011; Please vote if you find this posting was helpful or Mark it as answered.

    Wednesday, October 12, 2011 5:56 PM

All replies

  • Select MainQry.*, SubQry.*

    From Database1.dbo.table1 As MainQry Inner Join Database2.dbo.Table2 As SubQry On MainQry.PK = SubQry.PK

     

    Check INNER JOIN in BOL.


    Best Wishes, Arbi --- MCC 2011; Please vote if you find this posting was helpful or Mark it as answered.

    Wednesday, October 12, 2011 5:56 PM
  • please see the link

    http://tsqlexamples.com/joins.aspx

    VT


    Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker
    Wednesday, October 12, 2011 6:05 PM