天天看點

查詢部門下所有子部門(sqlserver2005)

條件:部門ID

結果:傳回所有該部門下的子部門集合

with hgo as( select *,0 as rank from TDEPT t where t.cid='"+id+"'   union all   select h.*,h1.rank+1 from TDEPT h join hgo h1 on h.cpid=h1.cid ) select * from hgo"