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
EdwardPeterAsked:
Who is Participating?
 
HilaireConnect With a Mentor Commented:
First you should the check the table owner,
You might have to prefix table names with owner name

ie
use owner.tablename rather than tablename alone

to check table owner, issue the following SQL Statement

select user_name(objectproperty(object_id('team_master'), 'ownerid'))
0
 
HilaireCommented:
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
0
 
EdwardPeterAuthor Commented:
Hilaire,

Thanks so much for your time and patience.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.