[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

stored function:Invalid object name

Posted on 2005-05-12
3
Medium Priority
?
203 Views
Last Modified: 2010-03-19
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
0
Comment
Question by:EdwardPeter
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Hilaire earned 2000 total points
ID: 13984421
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
 
LVL 26

Expert Comment

by:Hilaire
ID: 13984429
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
 

Author Comment

by:EdwardPeter
ID: 13984477
Hilaire,

Thanks so much for your time and patience.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question