• Sorry... the way my comment relates to the articles you cited and to Dwaine's article is that, while recursion is a mathematically sound way of expressing a problem, none of them explain that the use of recursive CTEs is usually not a good way to solve the problem either performance wise or resource usage wise simply because of the way SQL Server does the recursion. I'd like to see folks start to take a little responsibility in that area by doing a resource usage and performance comparison between the rCTE's and the equivalent While Loops.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)