January 20, 2016 at 7:53 am
Based on this thread it sounds as if you are dealing with a recursive CTE and I think you've received pretty good input.
With respect to SQL Server the only benefit I've seen to understanding recursion is that you can troubleshoot someone else's poorly performing code. If you ever get into functional programming (the article Sean posted makes mention of this) understanding recursion is important because functional programming languages are optimized for recursion.
Outside of that I think it's a cool mathematical concept.
-- Itzik Ben-Gan 2001
January 20, 2016 at 11:03 am
I did a quick search and looked through a few links on recursion. Here is one that I think explains the basics fairly well from a elementary standpoint.
http://www.cplusplus.com/articles/D2N36Up4/
----------------------------------------------------
January 20, 2016 at 11:13 am
As I see it Recursion in T-SQL is like paying taxes, something we would all like to avoid but some(read most)times that's not possible.
😎
January 21, 2016 at 2:07 am
To answer the original question; this
http://www.sqlservercentral.com/Forums/Topic1752249-1292-1.aspx
is recursion.
January 21, 2016 at 11:29 am
Chris Wooding (1/21/2016)
To answer the original question; thishttp://www.sqlservercentral.com/Forums/Topic1752249-1292-1.aspx
is recursion.
I would also call that an infinite loop. A Recursive function should have a cut off point. 😛
----------------------------------------------------
January 21, 2016 at 11:37 am
MMartin1 (1/21/2016)
Chris Wooding (1/21/2016)
To answer the original question; thishttp://www.sqlservercentral.com/Forums/Topic1752249-1292-1.aspx
is recursion.
I would also call that an infinite loop. A Recursive function should have a cut off point. 😛
There is one, when you get tired of being redirected to the same place over and over.
January 21, 2016 at 3:13 pm
The key question of recursion is in which cases is it the best approach ?
I remember the infamous factorial example - convenient to use to explain recursion in this very simple case. But often no warning given that this is the most inefficient way of calculating factorials. In fact, given the overhead involved, it is downright stupid to use recursion for factorials.
So when is the overhead warranted ?
Viewing 7 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply