2> CREATE PROCEDURE pass_params
3> @param0 int=NULL, -- Defaults to NULL
4> @param1 int=1, -- Defaults to 1
5> @param2 int=2 -- Defaults to 2
6> AS
7> SELECT @param0, @param1, @param2
8> GO
1>
2> EXEC pass_params -- PASS NOTHING - ALL Defaults
3> GO
----------- ----------- -----------
NULL 1 2
1>
2> EXEC pass_params 0, 10, 20 -- PASS ALL, IN ORDER
3> GO
----------- ----------- -----------
0 10 20
1>
2> EXEC pass_params @param2=200, @param1=NULL
3> -- Explicitly identify last two params (out of order)
4> GO
----------- ----------- -----------
NULL NULL 200
1>
2> EXEC pass_params 0, DEFAULT, 20
3> -- Let param1 default. Others by position.
4> GO
----------- ----------- -----------
0 1 20
1>
2> drop PROCEDURE pass_params ;
3> GO
|