• Bhargav Patel (7/1/2009)


    CTE really improves performance as always in most cases.

    Got some examples of that?

    CTEs are pretty much 'named subqueries'. The whole query still runs in one go just as it would if the query defined in the CTE was in a subquery, it's not like a temp table where the interim results are stored somewhere and then reused.

    Sometimes doing things all in one is faster. Sometimes dividing bits up and using temp tables is faster

    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