Results 1 to 2 of 2

Thread: OPENQUERY in a JOIN

  1. #1
    Join Date
    Dec 2004
    Posts
    502

    OPENQUERY in a JOIN

    What is the correct syntax for using OPENQUERY in a JOIN? For example, how would I use OPENQUERY in the following statement:

    SELECT *
    FROM server1.database1.dbo.table1 A INNER JOIN server2.database2.dbo.table2 B
    ON A.somefield = B.somefield
    WHERE A.someotherfield = 'whatever'

    When I tried something like this:

    SELECT * FROM
    OPENQUERY(server1, 'SELECT * FROM database1.dbo.table1 A INNER JOIN server2.database2.dbo.table2 B
    ON A.somefield = B.somefield
    WHERE A.someotherfield = ''whatever''')

    I got this error:
    MSDTC on server 'server1' is unavailable.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Try this

    SELECT * FROM
    OPENQUERY(server1, 'SELECT * FROM database1.dbo.table1) as A INNER JOIN server2.database2.dbo.table2 B
    ON A.somefield = B.somefield
    WHERE A.someotherfield = ''whatever''')


    But from the error message it looks like MS Distributed Transaction Coordinator service is not running in Server1.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •