O'Reilly logo

Programming Microsoft® SQL Server™ 2008 by Leonard Lobel, Andrew Brust, and Stephen Forte

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Querying Hierarchical Tables

With our hierarchical table populated and indexed, we’re ready to start writing efficient queries against it by using some more methods available on the hierarchyid type.

The IsDescendantOf Method

The IsDescendantOf method is invoked on one hierarchyid value and accepts another hierarchyid value as its parameter. It returns a bit (Boolean) value of 1 (true) if the hierarchyid that the method is invoked on is a descendant (either directly or indirectly) of the hierarchyid that is passed in as the parameter. Thus, this method essentially returns a subtree whose root is the node specified by the parameter. Because of its vertical traversal, it delivers very fast performance for tables that have a depth-first index.

We can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required