实际项目如遇到按照如地区这样树状结构的条件递归查询数据的场景中,可以使用。

CREATE FUNCTION [dbo].[GetAllChildrenTypeById]
(
@id varchar(50)
)
RETURNS TABLE AS RETURN
with cte as
(
SELECT [id]
,[dictionaryTypeCode]
,[text]
,[parentId]
,[sort]
,[availabl]
,[leaf]
,[url]
,[value] FROM [Dictionary] where ID = @id
union all
SELECT a.[id],a.[dictionaryTypeCode],a.[text],a.[parentId],a.[sort],a.[availabl],a.[leaf],a.[url],a.[value] FROM [Dictionary] a join cte b on a.[parentId] = b.Id
)
select id from cte GO

最新文章

  1. 八款常见的Android游戏引擎
  2. The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder is not applicable for the arguments
  3. beta版本贡献率
  4. linux grep和正则表达式
  5. VS2010在网络共享目录使用IntelliSense、ipch、sdf和SQL Compact Server相关问题
  6. 修改nagios密码和遇到的问题
  7. [bzoj4098] [Usaco2015 Open]Palindromic Paths
  8. java Properties类使用基础
  9. Oracle安装、Navicat for Oracle、JDBCl连接、获取表结构
  10. CountDownLatch、CyclicBarrier、Semaphore共同之处与区别以及各自使用场景
  11. SIOCGMIIPHY 和 SIOCSMIIREG 命令
  12. jsp 错误处理
  13. koa中间件机制详解
  14. dubbo控制器xml文件报错
  15. [转]xml解析工具的效率比较QDomDocument、TinyXml-2、RapidXml、PugiXml
  16. (转)JDK安装配置教程
  17. noip第2课作业
  18. .net 图片上传
  19. 【Java-Web】初始化加载Serlvet工程后-HttpServlet报错
  20. 面经:Google两轮背靠背

热门文章

  1. java 数字左补齐0
  2. Codeforces Round #554 (Div. 2) C. Neko does Maths(数学+GCD)
  3. 我的python中级班学习之路(全程笔记第一模块) (第一章)(第2部分:如何设置python中的字体颜色,猜年龄练习题解答,while else语句,pycharm的使用)
  4. MySql的Communications link failure解决办法
  5. Kindle复活记
  6. 贪吃蛇游戏——C语言双向链表实现
  7. rabbitmq - (消息队列) 的基本原理介绍
  8. Houdini Distributed Simulations and Render
  9. Sql语句基础练习(一)
  10. Go语言--数组、切片、