Dennis Post (9/10/2013)
Looks like a job for a recursive query.
Make up some sample data so we can help you out. (Create table + inserts + clean up)
Or you could check out the great SQLServerCentral articles
on the subject.
I believe that it's actually a job for a simple splitter and a tiny bit of pair matching. If we can get a more clear example from the OP of even just one of these "hierarchical paths", this will be a simple job to convert to an Adjacency List "Orchard". From there, the sky is the limit because we can then slave it into a multi-tree orchard. The "Orchard" here is very similar a task I did in the past where I had to organize such data into an "Orchard" of hundreds of thousands of "Trees" all "living" on common "ground". Once it was converted to an Adjacency List, the next step was to convert it to Nested Sets and that's a whole lot easier and faster to do than it's ever been before (and, yes, it then uses an rCTE as part of the process). Please see the following article on that.http://www.sqlservercentral.com/articles/Hierarchy/94040/
is pronounced ree-bar and is a Modenism for R
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Helpful Links:
How to post code problemsHow to post performance problemsForum FAQs