如果需要查询出 一个人的所有下级(子下级),我们可以使用这个存过
注意:查询所有的下级, 但是不包括自己!
Create PROC P_存储过程名字
@ID int
as
with temp
as
( select * from es_Agents where BelongsAgentOrgID=@ID union all select a.* from es_Agents as a inner join temp as child on a.BelongsAgentOrgID = child.AgentsID )
select * from temp