• RBarryYoung (1/5/2009)


    See that Update solution that I just posted in the "Cursors Be Gone" thread. It's got a derived table, that arguably could/should be a CTE: http://www.sqlservercentral.com/Forums/FindPost630181.aspx

    Thanks Barry, I missed that thread and it's got tons of useful info.

    Your update applies the UPDATE directly to the derived table! I would have expected a join to be necessary between the base table and the derived table with the UPDATE applied to the base table. How interesting!

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden