'T-SQL reflection on parameters

is it possible to use some kind of reflection on parameters in T-SQL module (function,procedure)?

procedure x(@foo nvarchar(max),@bar nvarchar(max)) ... 
set @foo = isnull(@foo,0); 
set @bar = isnull(@bar,0);

would it be possible to iterate over my parameters and set their values in a loop? Or do I need to use SQLCLR for this?



Solution 1:[1]

I don't know of any direct way, but you might find procedure

sp_executesql

useful, its like the exec function in most interpretted languages (run code from 'string'). Probably not the safest or most popular answer, but it could be powerful. What exactly are you trying to do? I can't really be too much more specific (or even sure this will help!) with what you've said so far.

Link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Glorfindel