|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, October 28, 2005 7:13 AM
Points: 18,
Visits: 1
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, February 01, 2012 6:49 AM
Points: 178,
Visits: 463
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, June 13, 2013 9:13 AM
Points: 1,415,
Visits: 1,211
|
|
The sample VB.net code for comparison contains both syntax and logic errors. In VB.Net, an IF is ended by "End If", not End. Also, "If result = number * Factorial(number - 1)" is attempted assignment and comparison and produces an incorrect result. If you run this code, you always get zero as a result. Refactored code: Private Function Factorial(ByVal number As Integer) As Integer If number = 0 Then Return 1 Else Return (number * Factorial(number - 1)) End If End Function
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, September 25, 2009 6:00 AM
Points: 3,
Visits: 13
|
|
Thanks for taking the time to post this article.
I'm curious as to performance compared to other methods of getting heirarchical data like adjacency, nested, etc.?
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, July 29, 2008 11:44 AM
Points: 4,
Visits: 5
|
|
the link to the previous article is wrong, it refers to the same article. http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=213&messageid=164149
I didn't know what CTE's were, glad I found out!! This was the final straw, I'm upgrading from 2000.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, May 10, 2010 1:29 PM
Points: 2,
Visits: 16
|
|
| Thanks for this article. I have one question here - how can I sort the result from CTE in hierarchical order as well as siblings on some orther order say all records of one level by firstname. In the article the example only sorts it ib hierarchical order
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, December 31, 2012 11:40 PM
Points: 1,
Visits: 51
|
|
Thanks for the article. My questions is : Suppose we need to relate one row data to two parents. By doing that I get only one instance of that data, not both. I've added : INSERT INTO dbo.SampleOrg SELECT 14, 'Senior Director - Finance', 5 It is not reasnable in this example but it is reasnable in other. How it should be done to accomplish this need.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, February 17, 2010 3:19 AM
Points: 3,
Visits: 10
|
|
Hi, One of the best example of recursive funtions in SQL. Thanks for posting such a nice example. Raj
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, July 16, 2012 10:19 AM
Points: 46,
Visits: 177
|
|
Nice explanation.
Assuming that a query is correctly structured, what in the data will cause extra rows in the query result. Does the recursion assume that each child has only one parent? What if this is not the case?
I have a table that has a "Father" field and "Child" field. Within the table a child can have more than one father. This is different from an org chart or an employee table where a child must have only one father. Is a recursive query possible when a child can have more than one father?
Thanks.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, May 10, 2012 10:40 AM
Points: 36,
Visits: 51
|
|
| I would also like to know what performance gains if any you get when using CTE's.
|
|
|
|