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
转载于:https://www.cnblogs.com/wlwjc/p/3580203.html