Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Recursively create Tree Structure Expand / Collapse
Author
Message
Posted Friday, January 18, 2013 6:10 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 3:25 AM
Points: 3,648, Visits: 5,328
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

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:13 AM
Points: 1,127, Visits: 1,594
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 Vijayan

For 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

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:13 AM
Points: 1,127, Visits: 1,594
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 Vijayan

For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden
Post #1409485
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse