• ChrisM@Work (6/18/2013)


    sagesmith (6/18/2013)


    Please post the times each approach takes, this is the only basis for a conclusion. As others have already mentioned, in many scenarios the cursor far outperforms the recursive cte.

    Over to you then. Sample data setup is a page or two back. I've compared iTally vs rCTE here:

    http://www.sqlservercentral.com/Forums/FindPost1464526.aspx

    Feel free to write your fastest cursor-based solution 😉

    My comment was for the author of the article who was comparing rCTE to Cursor. Your Tally approach is great for that sample scenario, no argument. I have found, as others have mentioned, that as you attempt to scale the rCTE approach the performance seems to go in an inverse relationship to the amount of rows. In these scenarios a Cursor or the Tally approach (inline or maybe faster as a Numbers table on disk?) does much better than the rCTE.

    I have seen these enlightened articles on rCTE before and I think they should come with a word of caution (unless I'm the one who is not enlightened? please prove me wrong).