熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> SQL Server >> 正文

sql server 2005中使用with實現遞歸的方法

2022-06-13   來源: SQL Server 

  

  復制代碼 代碼如下:

  WITH fw_requestion_note_temp(old_apply_id) AS ( 取根節點放入臨時表
SELECT old_apply_id FROM fw_requestion_note WHERE old_apply_id = eebcfbcdaef
根據已取到的數據遞歸取其字節點的數據

  UNION ALL SELECT fwold_apply_id FROM fw_requestion_note fw
 INNER JOIN fw_requestion_note_temp temp ON fwapply_id = tempold_apply_id ) SELECT old_apply_id FROM fw_requestion_note_temp


From:http://tw.wingwit.com/Article/program/SQLServer/201405/30733.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.