Using hierarchyid data type

This tutorial is intended for users who are experienced with Transact-SQL, but are new to the

data type.

This tutorial is divided into two lessons:

Lesson 1: Converting a Table to a Hierarchical Structure

In this lesson, you take an existing employee table that is structured as a parent/child hierarchy

and move the data into a new table that represents the hierarchy by using the

data

type. This lesson requires the

sample database.

Lesson 2: Creating and Managing Data in a Hierarchical Table

In this lesson, you create a table by using the

data type to represent the hierarchy

structure. Then, you manipulate the data in the table by using the hierarchical methods.

Your system must have the following installed:

Any edition of SQL Server 2008 (10.0.x) or later.

Either SQL Server Management Studio or Management Studio Express.

Internet Explorer 6 or a later version.

Tutorial: Getting Started with the Database Engine

Tutorial: Writing Transact-SQL Statements

hierarchyid Data Type Method Reference

Hierarchical Data (SQL Server)

hierarchyid (Transact-SQL)

AdventureWorks2025