• scogeb (9/13/2012)


    Jeff Moden (9/12/2012)


    Have you tried the NOT IN without the DISTINCT?

    Also, what's with all the LTRIM/RTRIM stuff? Data should be properly stored without leading spaces and trailing spaces hardly ever matter except when determining the actual number of bytes a strinng may contain.

    Yep, same deal with NOT IN without the DISTINCT, 100% CPU for way too long.

    Yeah, it will be. SQL ignores DISTINCT when specified in an IN/NOT IN subquery.

    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