Simon Hayes (sql@hayes.ch) writes:[color=blue]
> And since DEFAULT is a keyword, not a string, you can't use it in an
> expression, so this won't work either:
>
> select dbo.MyFunc(case when @i is null then DEFAULT else @i end)
>
> Unless I'm missing something, I'd say that default values in functions
> are not very useful in most cases (except perhaps as documentation),
> because the calling process has to have logic to call either func(value)
> or func(DEFAULT):
>
> if @i is null
> set @x = dbo.func(DEFAULT)
> else set @x = dbo.func(@i)[/color]
It's correct that default parameters with functions is bulky, but the above
scenario would be
if @i is null
set @x = dbo.func()
else set @x = dbo.func(@i)
in a more "normal" syntax. I know of know language where I can pass an
expression as a parameter, and the expression can evaluate to "actually
I am not passing this parameter at all".
The major drawback with the UDF syntax, is that you cannot add a new
parameter to a UDF without affecting existing callers.
--
Erland Sommarskog, SQL Server MVP,
esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp