MSSQL的递归查询
通过递归查询部门id为11的部门及其子孙部门
with dep as (
select * from department where dptid=11
union all
select d.* from Department d inner join dep p on d.DptParentID=p.DptID
) select * from dep
通过递归查询部门id为11的部门及其子孙部门
with dep as (
select * from department where dptid=11
union all
select d.* from Department d inner join dep p on d.DptParentID=p.DptID
) select * from dep