我在 SQL Server 中使用 HierarchyId,我参考下面的文章来获取所有祖先
https://technet.microsoft.com/en-us/library/bb677212%28v=sql.105%29.aspx
我有以下代码:
DECLARE @last_child HIERARCHYID
select *
FROM dbo.Geography AS g
WHERE @last_child.GetAncestor(1) = 0x58
SELECT @last_child
我在 DB 中有一个 id 为 0x58 的节点,它确实有一个孩子。但是,@last_child 出于某种原因不断返回 null。我做错什么了吗?