Call now: (800) 766-1884  


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA

 SQL Server Scripts
 Scripts Menu




  SQL Server Tips by Gama and Naughter

Default values

A parameter from an SP might have a value that is constant for most situations and it would be simpler to make it optional and with a default value. This way, the XP call would have it included in its parameters, the few times its value would be different from the default value. If the parameter is passed by location, the last one can be omitted, if it is optional, meaning that it will take the default value. The keyword DEFAULT, if used in the position of a certain parameter, causes that parameter to take its default value. If no default value is defined an error message is generated. If the parameter is passed by name, the missing name could mean that the parameter should take the default value.

This example is an XP that takes two parameters, the second one taking a default value when omitted. The output is the concatenation of both input values, separated by a space character, and all lowercase, with the exception of the first characters from both input parameters. When validating the input, the number of parameters will be in a range, in this example it is only from one to two but it could be more, depending on the number of default parameters. A Boolean variable can store whether a parameter will have its default value assigned or not. This variable will determine if the parameterís data is to be retrieved or ignored and, before processing the data, it will serve as a flag to ensure that the default value is stored in the corresponding temporary variable.

The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter  


Burleson Consulting Remote DB Administration







Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.

Burleson Consulting
SQL Server database support


Copyright © 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter