create function GetPath
(
@id uniqueidentifier
)
returns nvarchar(500)
as
begin
declare @str nvarchar(500)
declare @pid uniqueidentifier
select @str=category,@pid=pid from category where id=@id
if @pid is not null
begin
set @str=dbo.GetPath(@pid)+','+@str
end
return @str
end
go
select dbo.GetPath(id) as namePath from category
drop function dbo.GetPath
表结构

附件:
您所在的用户组无法下载或查看附件