May 29, 2002 at 8:20 am
If I create a function as a user with sa_role, like so:
CREATE FUNCTION fPlusOne (@Input1 int)
RETURNS int AS BEGIN
declare @TheField int
select @TheField = @Input1 + 1
return @TheField
END
go
grant exec on fPlusOne to public
go
I still have to call this function like this (even when I run it as the same user that created it):
select dbo.fPlusOne(7)
??
If I call it like this:
select fPlusOne(7)
I get this error:
'fPlusOne' is not a recognized function name.
Thanks in advance!
apf
May 29, 2002 at 8:42 am
Not sure I understand what you want to know. If the questions is must you use dbo.function then yes, you have to specify the ownername when using a UDF. See BOL for more detail. Also if you do not supply the owner name but the user create a UDF if can smetimes be dbo as the owner (I am pretty sure dbo will be if user in sa_role) or sometimes the user login itself. It is better to be specific during creation.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
May 29, 2002 at 9:36 am
Thanks for your response. I see that I forgot to state my question, but you did guess it correctly!
I guess basically you're saying that when calling UDF's, you have to supply the object owner.
Any idea why it is handled differently than other objects (where the owner defualts to 'dbo')?
apf
May 29, 2002 at 10:37 am
Sorry other than to say they just didn't I don't know why they did this. May have something to do with the way existing functions don't belong to anyone and could be a conflicting issues, don't know.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply