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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 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

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