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 ...

Get Guru's Guide to SQL Server™ Stored Procedures, XML, and HTML, The 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.