Limitations
There are a number of limitations and restrictions that apply exclusively to UDFs:
Except for inline functions, the outer BEGIN…END pair is required with UDFs. This differs from procedures and triggers. Curiously, the outer BEGIN…END enclosure is not only not required with inline functions, it's not allowed; you'll get a syntax error if you try to include it.
Calls to scalar UDFs must be owner qualified. Note the dbo. prefix on the call to the Proper() function used earlier. There's an undocumented way around this requirement that we'll discuss momentarily.
The last statement in a UDF must be RETURN.
There are a number of restrictions on the T-SQL you can use inside a function. Basically, you aren't allowed to do anything that might ...
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