标签:sub zhang evel project art hierarchy csdn where hiera
sql层级结构
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级节点
这个网址说的比较详细
https://blog.csdn.net/zhanghongju/article/details/42584643
标签:sub zhang evel project art hierarchy csdn where hiera
原文地址:https://www.cnblogs.com/sanshengshitouhua/p/14361538.html