Join Query- Help!

  • Try this...

     

    SELECT A.*

    FROM CUSTOMERBRANCH  A

    WHERE NOT EXISTS (SELECT * FROM [SERVER].[DATABASE].DBO.TBCUSTBRANCH B WHERE A.ACCPACCODE = B.ACCPACCODE)


    Regards,

    Ganesh

  • Ganesh, thanks a stack! This is exactly what I needed!

  • Or use an ANSI OUTER JOIN:

    SELECT A.*

    FROM CUSTOMERBRANCH  A

        LEFT JOIN [SERVER].[DATABASE].DBO.TBCUSTBRANCH B

        ON A.ACCPACCODE = B.ACCPACCODE

    WHERE B.ACCPACCODE IS NULL

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Only one point:

    remote query will copy the whole remote table to local server. No use of index, no way for optimiser to do its job.

    So, on big tables this query will be really sloooow.

    _____________
    Code for TallyGenerator

Viewing 4 posts - 1 through 5 (of 5 total)

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