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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-08-25 : 08:14:37
|
| ashy writes "I have a scenario of traversing a tree like structure in sql, exactly like the structure specified in http://www.4guysfromrolla.com/webtech/sqlguru/q022000-2.shtmlWell, fine, this helps out in traversing the entire tree.But i need something specific. For eg: If i give any particular node, at any level, may be as a parameter, I need an sql query without any recursive function to get the node and its child's values of any levels?ThanksAshy" |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-08-25 : 08:25:24
|
| Hi Ashy, Welcome to SQL Team!We store: Level Parent ID (next higher level) Sibbling ID ("Next Elder sibbling" at the same level, NULL=FirstBorn) a Sequence number (OrderBy will provide "walking order" for the whole tree) Path (concatenation of the ID numbers of all parents stored as a fixed length, or delimited, string)For a given node we can find any parent by "splitting" its Path, and all children where their Path "starts with" the path of the node in question, or where the ParentID matches the current NodeID (depending on immediate children only, or all-generations of children)Dunno if that helps at all though!Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-08-25 : 09:05:36
|
cached copies of mine... (i'm moving so my site is down)Part1 Part 1Part2 Part 2Part3 Part 3Corey Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now." |
 |
|
|
|
|
|
|
|