親子関係を hierarchyid で表して、自分含めて自分より下位のデータを検索することがあったので、ちょっと確認。 階層データ (SQL Server) - SQL Server | Microsoft Learn とりあえずクエリはこんなの drop table if exists [階層型テスト] create table [階層型テスト] ( [PK] bigint not null primary key , [階層PK] hierarchyid not null index [IX_階層型テスト_階層PK] , [備考] nvarchar(max) ) ; begin tran ; with [cte] as ( select 0 as [seq] union all select [seq] + 1 from [cte] where [seq] < 99999 ) inse
![お だ のスペース](https://cdn-ak-scissors.b.st-hatena.com/image/square/06a15c64ba0ceec233d86d71001ebb29a9dcbf5d/height=288;version=1;width=512/https%3A%2F%2Fcdn.blog.st-hatena.com%2Fimages%2Ftheme%2Fog-image-1500.png)