• Jeff Moden - Tuesday, March 6, 2018 8:03 PM

    I'll also add that all those IN (SELECT DISTINCTs are a waste of clock cycles because IN will always stop at the first occurrence of whatever it is you're looking for except NULL.

    The optimiser's smarter than that, it knows they're not needed.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass