不明白错在哪里了?
ALTER function GetParentClassByCurClassID](@CurClassID int)
returns @t table
(PClassID int,
PClassName nchar(50),
PClassParentID int,
PClassIdentifier varchar(20)
)
as
insert into @t select PClassID,PClassName,PClassParentID,PClassIdentify from TproductClass where PClassID = @CurClassID;
while(@@rowcount > 0)
begin
insert into @t
select B.PClassID, B.PClassName, B.PClassParentID,B.PClassIdentify from @t A Inner Join TproductClass B on B.PClassID=A.PClassParentID
where B.PClassID Not In(select Distinct PClassID from @t)
end
select * from @t order by PClassID asc
return
go
------解决方案--------------------看错。。
ALTER function GetParentClassByCurClassID](@CurClassID int)
returns @t table
(PClassID int,
PClassName nchar(50),
PClassParentID int,
PClassIdentifier varchar(20)
)
as
begin
insert into @t select PClassID,PClassName,PClassParentID,PClassIdentify from TproductClass where PClassID = @CurClassID;
while(@@rowcount > 0)
begin
insert into @t
select B.PClassID, B.PClassName, B.PClassParentID,B.PClassIdentify from @t A Inner Join TproductClass B on B.PClassID=A.PClassParentID
where B.PClassID Not In(select Distinct PClassID from @t)
end
return
end
go