--创立存储历程
createproceduresp_test
as
begin
select
a.node_id,
a.parentNode_id,
a.node_text,
b.node_idasancestor_id,
b.node_textasancestor_text
into
#t
from
xkb_treeNodea,xkb_treeNodeb
where
a.parentNode_id=b.node_idanda.isModule=1
while(exists(select1fromxkb_treeNodea,#tbwherea.node_id=ancestor_idanda.parentNode_id!=-1))
begin
update#t
set
ancestor_id=b.p_id,
ancestor_text=b.p_text
from
#ta,
(select
c.node_id,
d.node_idasp_id,
d.node_textasp_text
from
xkb_treeNodec,xkb_treeNoded
where
c.parentNode_id=d.node_id)b
where
a.ancestor_id=b.node_id
end