alter procedure DelereNote
@id int--定义要删除树节点
as
declare @childID int--声明变量
declare cursors cursor local for select id from test where [email protected] 全局游标
open cursors
fetch next from cursors into @childID--取游标的值赋给变量
while(@@FETCH_STATUS=0)--判断当前游标内是否存在值
begin
exec DelereNote @childID--递归调用存储过程 把孩子节点的值赋给游标 递归调用
fetch next from cursors into @childID--继续读取游标里面的内容
end
close cursors
deallocate cursors
delete from test where [email protected]
exec DelereNote 6--调用储存过程对于递归调用不很容易理解 需要多加练习
详细解决方案
节点 删除父节点时剔除子节点的存储过程
热度:358 发布时间:2016-05-04 23:18:05.0
相关解决方案