Specifies the keyword DEFAULT in place of a parameter.
For additional syntax information for the EXECUTE statement, see the Microsoft SQL Server Transact-SQL Reference.
EXECute procedure_name [parameter [, parameter2 [..., parameterN ]]]
where
The DEFAULT keyword allows you to generically specify that a parameter's default value be used.
When the procedure expects a value for a parameter that does not have a defined default and either a parameter is missing or the DEFAULT keyword is specified, an error occurs.
This example creates a stored procedure with default values for the first and third parameters. When the procedure is run, these defaults are inserted for the first and third parameters if no value is passed in the call or if the default is specified. Note the various ways the DEFAULT keyword can be used.
--- create the stored procedure --- CREATE PROC proc_calculate_taxes (@p1 SMALLINT = 42, @p2 CHAR(1), @p3 VARCHAR(8) = 'CAR')
The proc_calculate_taxes stored procedure can be executed in many combinations:
EXECUTE proc_calculate_taxes @p2 = 'A' EXECUTE proc_calculate_taxes 69, 'B' EXECUTE proc_calculate_taxes 69, 'C', 'House' EXECUTE proc_calculate_taxes @p1 = DEFAULT, @p2 = 'D' EXECUTE proc_calculate_taxes DEFAULT, @p3 = 'Local', @p2 = 'E' EXECUTE proc_calculate_taxes 69, 'F', @p3 = DEFAULT EXECUTE proc_calculate_taxes 95, 'G', DEFAULT EXECUTE proc_calculate_taxes DEFAULT, 'H', DEFAULT EXECUTE proc_calculate_taxes DEFAULT, 'I', @p3 = DEFAULT