• Interesting problem. Thanks for posting. I must confess I have not yet read the whole article, but from what I've seen (replacing a cursor or a while loop with a recursive CTE), I have a number of questions:

    1) Wouldn't it be possible to do the same thing using a tally table? See http://www.sqlservercentral.com/articles/T-SQL/62867/

    2) What metrics are you using to determine which method is faster?

    As far as I'm aware, recursive CTEs are RBAR just like cursors and while loops.

    Cheers

    GPO

    (now I'll go back and read it properly to see whether I've just made a goose out of myself!)

    ...One of the symptoms of an approaching nervous breakdown is the belief that ones work is terribly important.... Bertrand Russell