January 13, 2016 at 10:00 am
Could someone explain recursion to me?
January 13, 2016 at 10:03 am
This is a big topic. https://en.wikipedia.org/wiki/Recursion_%28computer_science%29
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
January 13, 2016 at 10:11 am
I got through the first few paragraphs................way to much for my little brain.
Thanx.
January 13, 2016 at 10:37 am
A lighter way to introduce the topic to folks for the first time, I have found, is through the The Droste Effect.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 13, 2016 at 10:48 am
Thanx. That does make it clearer. So, in a sense, if I get a "maximum recursion" error then, the code reached it's maximum number of "images" within the "image"?
January 13, 2016 at 10:49 am
"In order to understand recursion, one must first understand recursion"
It's mostly used when some code calls itself either directly or indirectly. For it to work, you need to find a way to stop the call or you'll enter an infinite loop.
January 13, 2016 at 11:17 am
NineIron (1/13/2016)
Thanx. That does make it clearer. So, in a sense, if I get a "maximum recursion" error then, the code reached it's maximum number of "images" within the "image"?
Precisely, but the max number of pictures and the max limit of recursion in SQL Server are system-imposed limits. In the case of the picture-system it's the clarity of the image and in the case of SQL Server it's a stack where an upper bound was wise to implement to preserve system stability, but in theory recursion can go on forever.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 13, 2016 at 11:24 am
I'm running a procedure that I received from a vendor and I got a maximum recursion 100 error or something like that. So, this means that it "looped" 99 or 100 times then threw the error?
January 13, 2016 at 11:28 am
NineIron (1/13/2016)
I'm running a procedure that I received from a vendor and I got a maximum recursion 100 error or something like that. So, this means that it "looped" 99 or 100 times then threw the error?
Yes, you hit the Max Recusion limit on the query. This is a lot of times a circular reference in the data it is using.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 13, 2016 at 11:42 am
Orlando Colamatteo (1/13/2016)
NineIron (1/13/2016)
I'm running a procedure that I received from a vendor and I got a maximum recursion 100 error or something like that. So, this means that it "looped" 99 or 100 times then threw the error?Yes, you hit the Max Recusion limit on the query. This is a lot of times a circular reference in the data it is using.
Or maybe someone used a recursive CTE to count or generate rows. Either way, the procedure should be corrected.
January 13, 2016 at 11:52 am
Luis Cazares (1/13/2016)
Orlando Colamatteo (1/13/2016)
NineIron (1/13/2016)
I'm running a procedure that I received from a vendor and I got a maximum recursion 100 error or something like that. So, this means that it "looped" 99 or 100 times then threw the error?Yes, you hit the Max Recusion limit on the query. This is a lot of times a circular reference in the data it is using.
Or maybe someone used a recursive CTE to count or generate rows. Either way, the procedure should be corrected.
Could be. There are multiple ways to exhaust the limit.
NineIron, are you at liberty to share the query showing the issue?
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 13, 2016 at 12:10 pm
Sorry, no.
January 15, 2016 at 7:25 pm
If you do a search on something along the lines of "Employees table and CTE query to show who reports to who" you will get the main go to example that probably most of us learned from concerning the concept of recursion, as it relates to set based operations here.
The two main elements in a recursive query are the 1) seed 2) recursive portion, both are combined in the CTE with Union All operator. Try to do a little reading as this is a bit involved.
----------------------------------------------------
January 20, 2016 at 5:12 am
Will do. Thanx.
January 20, 2016 at 6:53 am
To me (programming wise), recursion is nothing more than a loop and has all of the same problems as a loop except there's no explicit loop making it a bit of a black box, which makes it a bit more difficult to understand and troubleshoot when compared to a normal loop.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 15 posts - 1 through 15 (of 21 total)
You must be logged in to reply to this topic. Login to reply