Sqlserver中with的简单用法

Sqlserver中with的简单用法

以下示例是为实现递归效果的SQL

with Tree as
   (
     select * from T_Function
     where FunctionId = 1
     union all
     select T_Function.* from Tree, T_Function
     where
     Tree.FunctionId = T_Function.fatherid
   )
  select *
  from Tree

posted @ 2013-08-05 14:44  小小的风  阅读(998)  评论(0)    收藏  举报