overwriting arguments in t-sql functions
- by chuck taylor
I was playing around with some code and realized that it is possible to overwrite the argument to a t-sql function. i.e.,
create function someFn(@date date) as
begin
if @date is null set @date = getdate()
will set @date to be today's date if the argument was null.
This appears only to make any sense if t-sql is treating their arguments as references not values. I realized that I don't actually know what the t-sql rules are for cases like this and was hoping someone could elaborate what is going on here. (I don't ever recall seeing any value vs. reference discussion with respect to t-sql code for that matter actually..)