--查询所有下级DECLARE @BOSS hierarchyidSELECT @BOSS=orgNode FROM subjectClass WHERE ID=1011SELECT *,orgNode.ToString() as org FROM subjectClass WHERE orgNode.IsDescendantOf(@BOSS)=1 and valid=1--查询所有上级DECLARE @Employee hierarchyidSELECT @Employee=orgNode FROM subjectClass WHERE ID=11749SELECT *,orgNode.GetLevel()AS Level FROM subjectClass WHERE @Employee.IsDescendantOf(orgNode)=1 and valid=1
posted on 2016-12-19 16:07 阅读( ...) 评论( ...)