Groups | Blog | Home
all groups > sql server mseq > february 2004 >

sql server mseq : User Function Syntax


KLomax
2/6/2004 9:40:15 AM
In the statement below, the function name need's to be
prefixed with "dbo." to work. Is there anyway to make a
User Function visible without specifying the user? Meaning
is there a way to make "SELECT Answer = fnPlusOne(2)" a
valid statement?

CREATE FUNCTION fnPlusOne( @Value int )
RETURNS int
AS
BEGIN RETURN @Value + 1 END
SELECT Answer = dbo.fnPlusOne(2)

Thank you in advance.
Vishal Parkar
2/6/2004 11:21:44 PM
hi klomax,

When invoking scalar user defined function you will have to use minimum two-part
name of the function ie "owner" and "function name"
Ex
select owner_name.function_name (parm1,para.2....)

Whereas Table-valued functions can be invoked using a single part name.
Ex:
select * from function_name (parm1,para.2....)


--
Vishal

AddThis Social Bookmark Button