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


SP with Input and Output parameters

The output of an SP could also be returned in an output parameter. This way a variable is used to store the output from the SP. This example is very simple: it changes the first character of the input to upper case and the rest to lower case.

--Capitalizes first char, changes the rest to lower case
--SP with one input parameter and one output parameter
SET @nameCap=UPPER(LEFT(@name,1))+LOWER(RIGHT(@name,LEN(@name)-1))

SP with a parameter that is both Input and Output

In some situations, there is no need to store the output into an extra variable because the output must replace the input.

--Capitalizes first char, changes the rest to lower case
--SP with one input/output parameter
SET @name=UPPER(LEFT(@name,1))+LOWER(RIGHT(@name,LEN(@name)-1))

SP with named parameters

The SP cap1 from the first example is fine for this example, as well. So far these examples called SPís with the parameters specified by their location, that is, the position of the values to be passed to the SP defines which parameters will receive those values. It is very easy to call an SP with named parameters:

* The advantages of the order of the parameters becoming irrelevant are:
* Adding parameters to the SP without having to supply unnecessary ones when calling.
* Determining missing parameters for error handling or as optional parameters.
* Using default parameters without having to fill them with NULLís.

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