create proc 过程名
@参数 int
as
declare @tmp1 table (ID int,ParID int)
insert @tmp1 select ID,ParID from Node where ID= @参数while exists(select 1 from Node a,@tmp1 b where a.ParID=b.ID and a.ID not in (select ID from @tmp1))
  insert @tmp1 select a.id,a.parid from  Node a,@tmp1 b where a.ParID=b.ID and a.ID not in (select ID from @tmp1)select sum([money]) 结果 from item where Nodeid in (select id from @tmp1)