declare @HID Hierarchyid
SELECT @HID=HID FROM dbo.ProjectSub WHERE AID=274
SELECT @HID as HID --0x4AD72AC0 5级节点 水冷壁
SELECT @HID=@HID.GetAncestor(@HID.GetLevel()-3).ToString()等同于SELECT @HID=@HID.GetAncestor(2).ToString()
SELECT @HID as HID --0x4AD6
select * from ProjectSub where HID=0x4AD6 --测试项目1 是3级节点
select * from ProjectSub where HID=0x4AD72AC0 --水冷壁 是5级节点
5级节点的祖先是4级节点、3级节点