---查找类型下的所有子类型包括当前类型
alter function F_Type
(
@ID int
)
returns @t_Level table (ID int,Level int)
as
begin
declare @Level int
set @Level=1;
insert @t_Level select @ID,@Level
while @@rowcount>0
begin
set @Level=@Level+1;
insert @t_Level select a.ID,@Level from TB_ArticleType a,@t_Level b where a.ParentID=b.ID AND b.Level=@Level-1
end
return
end