According to BOL, SET commands aren't allowed in the function body. See CREATE FUNCTION in BOL for details.
>Server: Msg 443, Level 16, State 2, Procedure ISOweek, Line 8
>Invalid use of 'SET COMMAND' within a function.
>
>Error 443 is explained in TSQL help as
>'Invalid use of '%s' within a function. ' which is great to know, but how do I get around that?
< snip >
--sb--