Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Msg 208 err too

Status
Not open for further replies.

slatet

Programmer
Sep 11, 2003
116
0
0
US
I have read the posts on 208 and they do not help me. When I try to call a function from a procedure in query analyzer, I get that error. I am positive that the database is correct, the name is spelled correctly, and the function does in fact exist the the correct database and still the error. Any other ideas?
 
Function is called with or without ownership prefix (owner.blah())?

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
The owner is dbo, the name of the function is dbo.fn_blahblah and I call it using the same - dbo.fn_blahblah.
 
Is this a table valued function or a scalar function?

Do this...

sp_helptext fn_blahblah

There will be a Returns line, copy/paste that here.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
CREATE FUNCTION dbo.fn_NoViewTaskRouteSection(@Section int)

RETURNS bigint

AS

BEGIN
Declare @ReturnTaskID bigint

Select @ReturnTaskID = TaskRouteTaskID
From vw_TaskRouteSections
Where ((TaskRouteStatus <> 1 And TaskRouteType = 2) OR TaskRouteType =1) AND (@Section = TaskRouteSection)

Return @ReturnTaskID
END



 
This is a scalar valued function (because it does not return a table).

Try testing this by using the Query Analyzer

Select dbo.fn_NoViewTaskRouteSection(1)

You can change the 1 to any other meaningful integer.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
If you want to run this over many records, then the syntax would be....

Code:
Select FieldList, 
       dbo.fn_NoViewTaskRouteSection(FieldThatRepresentsSection)
From   Table

You should be made aware that functions are slower to perform (especially in this manner) because it must be evaluated for each record in the table.

I suspect that your usage of this function could probably be eliminated, which would improve performance.

I've said it before, and I'll say it again. I only use functions when I want to hide complexity [red]and[/red] reuse the code. If both criteria are not met, then don't use a function. This is my opinion (others may disagree).

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top