Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Recursively create Tree Structure Rate Topic Display Mode Topic Options
Author
 Message
 Posted Friday, January 18, 2013 6:10 AM
 Hall of Fame Group: General Forum Members Last Login: Yesterday @ 9:05 PM Points: 3,594, Visits: 5,104
 Rats! Now why didn't I think of that?+1 Peter My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!My thought question: Have you ever been told that your query runs too fast?My advice:INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.Need to UNPIVOT? Why not CROSS APPLY VALUES instead?Since random numbers are too important to be left to chance, let's generate some!Learn to understand recursive CTEs by example.Splitting strings based on patterns can be fast!
Post #1408861
 Posted Saturday, January 19, 2013 12:12 AM
 Ten Centuries Group: General Forum Members Last Login: Tuesday, April 08, 2014 2:40 AM Points: 1,118, Visits: 1,573
 Thank You very much Peter. Your solution is working very well....Let me do some more testing and will get back if something's missing. Thank you Dwain for all your efforts. Vinu VijayanFor better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden
Post #1409165
 Posted Monday, January 21, 2013 4:54 AM
 Ten Centuries Group: General Forum Members Last Login: Tuesday, April 08, 2014 2:40 AM Points: 1,118, Visits: 1,573
 Hello again guys.....how are you doing?The query is working perfectly fine. I have implemented the query and tested it for a tree having sub trees till the eighth level. Peter, i am still not very clear with the adding of the 0s to the TreeOrder string. Could you please tell me the logic behind doing so.....would love to know.Dwain, I'm really sorry for the missing commas in the Insert statements........My mind was completely occupied with the query even when I was posting the sample data.....but u still beat me to it Vinu VijayanFor better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden
Post #1409485

 Permissions