sql 获取指定节点的所有父节点或者所有子节点
获取节点的所有父节点 ;with #tmp as( select * from tb where id = 'DMA20120327036' union all select a.* from tb a, #tmp b where a.id = b.pid ) select * from #tmp 获取节点的所有子节点 ;with #tmp as( select * from tb where id = 'DMA20120327036' union all select a.* from tb a, #tmp b where a.pid = b.id ) select * from #tmp