SQL Server 没有类似于Oracle START WITH NAME='xx' CONNECT BY PRIOR ID=PARENT_ID这样的语句,但是可以通过自定义标准函数+With语句实现,速度也是杠杠的

ALTER FUNCTION  [dbo].[RecursionSysLocation]
(
-- Add the parameters for the function here
@ParentId nvarchar(36)
)
RETURNS TABLE
AS
RETURN
(
with temp ( [Id], [parentid])
as
(
select Id, ParentId
from SysLocation
where ParentId = @ParentId
union all
select a.Id, a.ParentId
from SysLocation a
inner join temp on a.ParentId = temp.[Id]
) select s.Id, s.ParentId from SysLocation s where Id=@ParentId
union all
select * from temp
)

最新文章

  1. EffectiveJava——请不要在代码中使用原生态类型
  2. rabbitmq心跳机制与配置
  3. codeforces gym 100286 H - Hell on the Markets (贪心算法)
  4. RSpec自定义matcher
  5. POJ1002487-3279(map)
  6. [转] What is the point of redux when using react?
  7. In Depth : Android Shutdown Sequence
  8. leetcode Valid Sudoku python
  9. 腾讯视频国际版(Android)电量测试方法研究与总结
  10. 访问者模式 Visitor 行为型 设计模式(二十七)
  11. CentOS7 VMware-Tools安装与共享文件夹设置
  12. 翻译NYOJ
  13. 如何从日期对象python获取以毫秒(秒后3位小数)为单位的时间值?
  14. 分布式系统监视zabbix讲解十一之zabbix升级--技术流ken
  15. [JLOI2016/SHOI2016]侦察守卫(树形dp)
  16. STL-容器库101--array【C11】
  17. 【Linux】字符转换命令paste
  18. POI初体验
  19. LeetCode: Linked List Cycle 解题报告
  20. minigui杂项

热门文章

  1. 用Java来写常见的排序算法
  2. 关于li元素嵌套的事儿
  3. nginx tomcat session丢失的问题
  4. 渐进式框架、自底向上增量开发的vue
  5. composer 报错:Your requirements could not be resolved to an installable set of packages 解决方法
  6. Ubuntu14.04源
  7. python scipy学习-曲线拟合
  8. mysql 5.7 的安装配置与 navicat premium for mysql 11 的破解使用
  9. spring mvc 中文参数乱码
  10. Nginx + Tomcat Windows下的负载均衡配置