create procedure DeleteNote
@Objid int--定义要删除树节点
as
declare @childID int --声明变量
declare cursors cursor local for select Objid from TableChart where parentid=@Objid --local关键字全局游标
open cursors
fetch next from cursors into @childID --取游标的值赋给变量
while(@@FETCH_STATUS=0) --判断当前游标内是否存在值
begin
exec DeleteNote @childID --递归调用存储过程把孩子节点的值赋给游标递归调用
fetch next from cursors into @childID --继续读取游标里面的内容
end
close cursors
deallocate cursors
delete from TableChart where objid=@Objid ----存储过程执行的删除方法