How can I apply for queries only for records that are “leaf nodes only” (i.e. no children)?
I tried a query like this:
select *
from TableA tt
where tt.HierarchyId.GetDescendant(null, null) not in
(
Select t.HierarchyId
from TableA t
)
But it still returned some nodes that had children.
I use the built-in hierarchy data type (part ms sqlserver)
Marty source
share