Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
bis188
Starting Member
3 Posts |
Posted - 2005-02-11 : 01:45:49
|
| I need some help to flattern a hirearchy. Say I have something like N | 1 / 2 3 /4 5 / 6My source table isNode, Parent1 null2, 13, 14, 25, 26, 5I want to output a table like this with 4 columnslev1, levl2, levl3, level4===== ====== ====== ====== 1 null null null 1 2 null null 1 3 null null 1 2 4 null 1 2 5 null 1 2 5 6Of course this is a cut down version of the real problem.I have 35 thousand rows of data like this to deal with, thegood news is I know there is a maxium of 15 levels. I am not surehow to work this, at any given row in my source table, I have only a parent and child info and I don't know which level it belongs.There must be an algorithum out there expand this.Can you help please and thank you ! |
|
|
bis188
Starting Member
3 Posts |
Posted - 2005-02-11 : 01:52:10
|
| I just notice the post scramble up my "graph" but I think you all know what I meant. It's 4 level with1 on top, 2 & 3 on the 2nd level , 4 & 5 on the 3rd and 6 the fourth level. I want to flattern out with 6 records and each record has 4 columns (because that's how deep the graph is).Thank you again ! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|