|
To pass a optional parameters to a stored procedure in SQL Server, declare the parameter with the default value.
Create Procedure proc_Test
@a int,
@b int =5 -- Provided with the default value.
as
begin
Select @a, @b
end
Note:
When using optional parameters at first, specify it with the parameter name during execution
For example, if @a is an optional parameter, to execute this stored proecedure, specify it as follows
EXEC proc_Test @b=3