Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Article Discussions
»
Article Discussions by Author
»
Discuss content posted by Rafal S.
»
Generating number sequences with Common Table...
Generating number sequences with Common Table Expressions
Rate Topic
Display Mode
Topic Options
Author
Message
skra
skra
Posted Saturday, February 09, 2008 7:11 AM
Say Hey Kid
Group: General Forum Members
Last Login: Yesterday @ 4:11 AM
Points: 711,
Visits: 210
Comments posted to this topic are about the item
Generating number sequences with Common Table Expressions
Post #453583
ChrisM@Work
ChrisM@Work
Posted Tuesday, October 04, 2011 2:53 AM
SSCertifiable
Group: General Forum Members
Last Login: 2 days ago @ 9:27 AM
Points: 5,618,
Visits: 10,990
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.
“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.”
- Gail Shaw
For fast, accurate and documented assistance in answering your questions, please read
this article
.
Understanding and using APPLY, (I)
and
(II)
Paul White
Hidden RBAR: Triangular Joins
/
The "Numbers" or "Tally" Table: What it is and how it replaces a loop
Jeff Moden
Exploring Recursive CTEs by Example
Dwain Camps
Post #1185092
nigel.
nigel.
Posted Tuesday, October 04, 2011 3:03 AM
Ten Centuries
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 7:31 AM
Points: 1,164,
Visits: 2,601
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
Useful Links:
How to post data/code on a forum to get the best help
The "Numbers" or "Tally" Table - Jeff Moden
Post #1185095
skra
skra
Posted Tuesday, October 04, 2011 3:12 AM
Say Hey Kid
Group: General Forum Members
Last Login: Yesterday @ 4:11 AM
Points: 711,
Visits: 210
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:
http://www.sqlservercentral.com/scripts/61950/
Post #1185099
nigel.
nigel.
Posted Tuesday, October 04, 2011 3:20 AM
Ten Centuries
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 7:31 AM
Points: 1,164,
Visits: 2,601
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
Useful Links:
How to post data/code on a forum to get the best help
The "Numbers" or "Tally" Table - Jeff Moden
Post #1185104
ChrisM@Work
ChrisM@Work
Posted Tuesday, October 04, 2011 3:23 AM
SSCertifiable
Group: General Forum Members
Last Login: 2 days ago @ 9:27 AM
Points: 5,618,
Visits: 10,990
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
“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.”
- Gail Shaw
For fast, accurate and documented assistance in answering your questions, please read
this article
.
Understanding and using APPLY, (I)
and
(II)
Paul White
Hidden RBAR: Triangular Joins
/
The "Numbers" or "Tally" Table: What it is and how it replaces a loop
Jeff Moden
Exploring Recursive CTEs by Example
Dwain Camps
Post #1185106
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.