Setting Default Values for Parameters

You can assign a default value to a parameter by specifying a value in the definition of the parameter, as shown in Listing 28.11.

Listing 28.11 Assigning a Default Value for a Parameter in a Stored Procedure

image

You can have SQL Server apply the default value for a parameter during execution by not specifying a value or by specifying the DEFAULT keyword in the position of the parameter, as shown in Listing 28.12.

Listing 28.12 Applying a Default Value for a Parameter When Executing a Stored Procedure

image

Tip

If ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.