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 |
|
DashboardMan
Starting Member
2 Posts |
Posted - 2011-06-26 : 07:49:20
|
| I am using hierarchyID, and I am trying to find all the nodes at the bottom of the hierarchy. For example if the hierarchy is:AAAAAAAAAA <AAAB <ABABAABAA <ABAB <Then the query would return:AAAAAAABABAAABABAny suggestions?DashboardMan |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-06-26 : 08:47:50
|
If you are looking for all nodes that don't have any children, you should be able to do it like this: select * from YourTable y1 where not exists ( select * from YourTable y2 where y2.HierarchyIdColumn.GetAncestor(1) = y1.HierarchyIdColumn ) Is that what you are looking for, or are you looking for nodes at a specific level? If you are, a where clause such as "WHERE HierarchyIdColumn.GetLevel()=4" should be able to get that information. |
 |
|
|
DashboardMan
Starting Member
2 Posts |
Posted - 2011-06-26 : 09:33:16
|
| That's it! Thanks for the quick response.DashboardMan |
 |
|
|
|
|
|