Scalar UDFs
Scalar UDFs return a single (scalar) value. They can be specified where scalar expressions are allowed–for example, in a query, constraint, computed column, and so on. Scalar UDFs have several syntactical requirements. Scalar UDFs:
Must have a BEGIN/END block defining their body.
Must be schema qualified when invoked (unless invoked as stored procedures with EXEC, as in EXEC myFunction 3, 4).
Do not allow omitting optional parameters (ones that have default values) when invoked; rather, you must at least specify the DEFAULT keyword for those.
The following sections explore both T-SQL and CLR UDFs.
T-SQL Scalar UDFs
T-SQL UDFs are typically faster than CLR UDFs when the main cost of their activity pertains to set-based data manipulation, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access