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