User-Defined Functions

SQL Server user-defined functions are created using the CREATE FUNCTION command . Any created function can take zero or more input parameters of any type except timestamp, cursor, or table. User-defined functions pass back a single value as defined in the RETURNS section of the CREATE FUNCTION. User-defined functions can return any data type except text, ntext, image, cursor, or timestamp.

All user-defined functions must comply with all naming standards set forth for all objects in the database. Unlike other objects in the database, when you call a user-defined function, you must use the qualified object name, in the format of owner_name . function_name , as follows :

SELECT * FROM dbo.fncReturnScalarValue

As with ...

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.