O'Reilly logo

Programming Microsoft® SQL Server® 2012 by Leonard Lobel and Andrew Brust

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

Reordering Nodes within the Hierarchy

Reorganizing the nodes within the tree structure is a common maintenance task when working with hierarchies. You might need to alter the tree structure by adjusting the parent-child relationships within the hierarchy. The hierarchyid type provides a GetReparentedValue method that makes it easy to handle this kind of maintenance. You will start by first relocating just a single node without disturbing any other nodes in the hierarchy. Then you’ll relocate an entire subtree (that is, all of a node’s descendant nodes).

The GetReparentedValue Method

You invoke the GetReparentedValue method on the node you want to move, passing in two parameters. The first specifies the original parent (the source), and the second ...

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