As with all else, "It Depends". If I need every millisecond of performance I can get, I'll use the physical Tally table with the understanding that, although they won't matter in this case, it'll cause a shedload of logical reads. I also have a Tally function that I can start at 0 or 1 if I need to avoid the reads for one reason or another. That function will also allow me to go to ridiculous counts for experimental purposes.
I usually use the Tally function on forums because too many people seem to either have a personal problem with using a physical helper table or they're simply not allowed to have such tables. If they not allowed either table or function, then I end up posting the code inline. And, no... I'll never use an rCTE for such things even if it's just for 10 rows. It's just not the right way to do it regardless of rowcount and especially since I've proven (many times) that a well written WHILE loop will be it in all cases of incremental counting.
And thank you for the very kind feedback.
is pronounced "ree-bar
" and is a "Modenism
" for R
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".
"If "pre-optimization" is the root of all evil, then what does the resulting no optimization lead to?"
How to post code problems
How to Post Performance Problems
Create a Tally Function (fnTally)