Calling User-Defined Functions

Calling or invoking a user-defined function is quite easy. All you have to do is specify the name of the function you are calling followed by a set of parentheses. Within the parentheses, you must specify any parameters being passed into the function. Of course, all parameters that you pass in must be in the same order as they are defined in the function.

Calling Scalar Functions

As mentioned previously, scalar functions can be used in T-SQL statements in any location that accepts the data type that the function returns. The following is a list of where you can use scalar functions :

  • In T-SQL queries, scalar functions are allowed in any of the following locations :

    • In the SELECT clause of a SELECT statement

    • In ...

Get Writing Stored Procedures for Microsoft SQL Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.