SQL Flow Field Guide

hierarchyid.GetReparentedValue

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

tree navigation GetReparentedValue

What changes

Input
hierarchyid instance and arguments
Output or change
hierarchyid
Return type
SQL Server return type:hierarchyid CLR return type:SqlHierarchyId

Syntax at a glance

node. GetReparentedValue ( oldRoot, newRoot )

Work example

Calculate a node's new path when moving it from one parent subtree to another.

Apply the same old and new roots to every descendant row in one reviewed transaction.

Check your work The method returns a changed path value but does not update table rows or descendant references.

Practice SQL

Open in SQL Flow
SELECT hierarchyid::Parse('/4/2/').GetReparentedValue(hierarchyid::Parse('/4/'), hierarchyid::Parse('/9/')).ToString() AS moved_path;

Open Microsoft Learn for full syntax, permissions, and details for your version.