Types of Functions

Officially, SQL Server supports three types of user-defined functions:

  • Scalar functions

  • Inline table-valued functions

  • Multistatement table-valued functions

The next few sections take an in-depth look at the differences between the function types and how and where you can use them.

Scalar Functions

Scalar functions are like the built-in functions provided with SQL Server. They return a single scalar value that can be used anywhere a constant expression can be used in a query, as you saw in the previous example of the getdateonly() function.

Scalar functions typically take one or more arguments and return a value of a specified datatype. All functions must return a result using the RETURN statement. The value to be returned can ...

Get Microsoft® SQL Server™ 2000 Unleashed, Second Edition 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.