tree

create function f_pid(@id varchar(3)) returns @t_level table(id varchar(3))  
as  
begin  
insert into @t_level select @id  
select @id = IDParent from NodeNet where IDChild = @id and IDParent is not null  
while @@ROWCOUNT > 0  
begin  
insert into @t_level select @id select @id = IDParent from NodeNet where IDChild = @id and IDParent is not null  
end  
return  
end  
go 

你可能感兴趣的:(tree)