February 9, 2008 at 7:11 am
Comments posted to this topic are about the item Generating number sequences with Common Table Expressions
October 4, 2011 at 2:53 am
Try option (MAXRECURSION 0).
This is by far the slowest of the CTE-based row (number) generation methods but as your code shows it's very easy to manipulate rCTE's to generate quite complex output.
[font="Arial"]βWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.β - Gail Shaw[/font]
October 4, 2011 at 3:03 am
Have a look at this too, by Itzik Ben-Gan:
http://www.sqlmag.com/article/sql-server/virtual-auxiliary-table-of-numbers
Should perform better than a recursive CTE.
Nigel
How to post questions
October 4, 2011 at 3:12 am
I am surprised that anyone is still reading it since it was published in february 2008 π
And about the Itzik Ben-Gan article (http://www.sqlmag.com/article/sql-server/virtual-auxiliary-table-of-numbers)
I also published script which uses similar method in january 2008:
October 4, 2011 at 3:20 am
skra (10/4/2011)
I am surprised that anyone is still reading it since it was published in february 2008 π
It is the "Featured Script" in todays news letter.
Nigel
How to post questions
October 4, 2011 at 3:23 am
nigel. (10/4/2011)
skra (10/4/2011)
I am surprised that anyone is still reading it since it was published in february 2008 πIt is the "Featured Script" in todays news letter.
What's "today"?
By Rafal Skotak, 0001/01/01
Total article views: 1163 | Views in the last 30 days: 132
[font="Arial"]βWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.β - Gail Shaw[/font]
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply