• Florian Reischl (11/7/2009)


    @Paul: Thanks for test data! 🙂

    You're very welcome. I'm hoping that if I do it enough, future posters will get the hint 🙂

    I know not everything in life is about performance, but if you compare the query plans for your preferred methods to the EXISTS version, I hope you will see why I prefer it.

    The EXISTS does not need a Stream Aggregate (present in both of your examples) and uses a left semi join instead of a left outer join. The obvious difference there is that the semi join stops processing as soon as it finds a match; the left outer join processes all matches.

    Query plans:

    1. EXISTS

    2. LEFT JOIN

    3. CTE

    Paul