Function calls as parameters are not allowed (except for those system functions prefixed @@
- i.e. those that used to be called global variables)
You need to assign to a variable.
Microsoft acknowledge this is less than great in this related Connect item: T-SQL: use scalar functions as stored procedure parameters
Agreed! More generally, wherever TSQL
expects, say, and integer value, it
should accept a literal, a variable,
or the result of a function whose
return type is integer. It just makes
the language more regular
("orthogonal") and easier to
learn/use.
That said, it's too late for this
feature in the Katmai release, but
I'll add it to our TODO list.