• Dalibor Margotic (3/29/2012)


    You need to eliminate hash join and Index scan.

    With this query you can do that using INTERSECT AND EXCEPT

    ...

    Or, this one using CTE AND JOINS:

    ...

    In the CTE and JOINS query, I would replace the IN clause with an EXISTS clause.

    But that could be personal preference.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP