Link to home
Start Free TrialLog in
Avatar of EdwardPeter
EdwardPeter

asked on

stored function:Invalid object name

Hi

Kindly assist how to resolved this error:

Server: Msg 208, Level 16, State 1, Procedure ufn_getorglist, Line 19
Invalid object name 'team_master'.

Thanks.



create function dbo.ufn_getorglist(@operatorid int)
returns @t table(operatorid int, supervisorID int) as
begin
declare @supervisorID int

select top 1 @supervisorID = supervisorID from
(select a.operatorid as supervisorid from operator_master a
inner join team_master b on b.teamid=a.teamid and b.supervisorid=@operatorid )z

while @@rowcount <> 0
begin
      insert into @t (operatorid, supervisorID) select *, @supervisorID from dbo.ufn_GetChildNodes(@supervisorID) d

      select top 1 @supervisoriD = supervisorID from
(select a.operatorid as supervisorid from operator_master a
inner join team_master b on b.teamid=a.teamid and b.supervisorid=@operatorid)z
where supervisorID > @supervisorID

end

return
End
Go
ASKER CERTIFIED SOLUTION
Avatar of Hilaire
Hilaire
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, the first select should have an "order by" IMHO or you will miss some records (top 1 whithout an order by will pick a random record)

select top 1 @supervisorID = supervisorID from
(select a.operatorid as supervisorid from operator_master a
inner join team_master b on b.teamid=a.teamid and b.supervisorid=@operatorid ) z
order by supervisorID
Avatar of EdwardPeter
EdwardPeter

ASKER

Hilaire,

Thanks so much for your time and patience.