SQL Flow Field Guide

hierarchyid.ToString

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

tree navigation ToString

What changes

Input
hierarchyid instance and arguments
Output or change
nvarchar(4000)
Return type
SQL Server return type:nvarchar(4000) CLR return type:String

Syntax at a glance

node.ToString ( )

Work example

Display or export a hierarchy path as its slash-delimited representation.

Keep the hierarchyid value for joins and path operations, and convert to text only at a display boundary.

Check your work ToString returns a textual path and string sorting is not a substitute for hierarchyid ordering.

Practice SQL

Open in SQL Flow
SELECT hierarchyid::Parse('/4/2/').ToString() AS display_path;

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