惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
MyScale Blog
MyScale Blog
Jina AI
Jina AI
B
Blog
Microsoft Security Blog
Microsoft Security Blog
T
Troy Hunt's Blog
博客园_首页
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
GbyAI
GbyAI
T
Tenable Blog
B
Blog RSS Feed
S
Securelist
T
Threat Research - Cisco Blogs
P
Privacy International News Feed
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
AWS News Blog
AWS News Blog
V
V2EX
宝玉的分享
宝玉的分享
J
Java Code Geeks
小众软件
小众软件
Spread Privacy
Spread Privacy
腾讯CDC
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
V
Visual Studio Blog
The Hacker News
The Hacker News
C
CERT Recently Published Vulnerability Notes
Project Zero
Project Zero
Know Your Adversary
Know Your Adversary
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
C
Check Point Blog
Webroot Blog
Webroot Blog
D
DataBreaches.Net
Cloudbric
Cloudbric
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家

博客园 - HelloSnoopy

写了个用一个文件定义样式的DataGrid 一个最基本的WebService+Flash调用的实例 [转载]如何奔向程序员打工的出头之日? 一定要讲给孩子们的20个小故事 人脉对职业生涯最重要 (转) 爱情的10种样子,送给懂爱的朋友们 装了Enterprise Library.NET 200501release C#判断是否为数字的最好速度! 开源的 BugTracker.net 错误跟踪管理系统 Enjoy new year of 2005! Flash AS2 用EventDispatcher广播事件 设计模式随笔-让众口不再难调 CodeSmith使用心得 [专题]MVC构架模式 使用Microsoft Application Block之Cache Application 用一条SQL完成数据表的行统计 如何使IFrame的长宽与内容自动适应大小 为Project提供一个统一风格的DataGrid asp.net forums中定时器的应用
用于读取树形任一节点下所有级别子节点的SqlServer UDF
HelloSnoopy · 2004-12-22 · via 博客园 - HelloSnoopy

SRC:http://blog.joycode.com/mmkk/archive/2004/05/13/21428.aspx

树形结构是应用中常用的数据结构,最简单的设计类似:
id,name,parent_id

这种最简单的设计通常需要结合递归来最终形成树形UI,而且,对于要取得某一个节点的所有下级节点也不是很方便,
出于这种考虑,使用如下UDF来简化这种操作:
--取得树形结构中当前节点的所有下级节点

CREATE FUNCTION [dbo].[GetChildCategories] (@parent_id int)  
RETURNS @work Table (num int IDENTITY(1,1),category_id intAS  
BEGIN 
declare @childrenCount int,@currCategory_id int,@num int
set @num = 1
insert @work
select category_id
from Category_Classification
where parent_id = @parent_id
set @childrenCount = @@ROWCOUNT
while (@num <= @childrenCount)
    
Begin
        
select top 1 @currCategory_id = category_id
        
From @work
        
Where num = @num
        
        
insert @work
        
select category_id
        
From Category_Classification
        
where parent_id = @currCategory_id
        
        
set @childrenCount = @childrenCount + @@ROWCOUNT
        
set @num = @num + 1
    
End
Return
END

主要是将一个递归操作转化为一个单一的循环操作,就这几句代码也不知道该怎么写注释了,
未有大数据量测试.