Invoking User-Defined Functions

Accessing and Changing Relational Data

Accessing and Changing Relational Data

Invoking User-Defined Functions

When you reference or invoke a user-defined function, you specify the function name followed by parentheses. Within the parentheses, you can specify expressions called arguments that provide the data to be passed in to the parameters. You cannot specify parameter names in the arguments when invoking a function. When you invoke a function, you must supply argument values for all of the parameters and you must specify the argument values in the same sequence in which the parameters are defined in the CREATE FUNCTION statement. For example, if a function named fn_MyIntFunc that returns an integer is defined with an integer parameter and an nchar(20) parameter, it can be invoked using:

SELECT *
FROM SomeTable
WHERE PriKey = dbo.fn_MyIntFunc( 1, N'Anderson' )

This is an example of invoking a function named fn_MyTableFunc defined to return a table:

SELECT *
FROM dbo.fn_MyTableFunc( 123.09, N'O''Neill' )

See Also

User-Defined Functions

CREATE FUNCTION