Output Parameters and Return Codes in SQL Server
Part one of a three-part series of blogs

This blog teaches you how to return values from your SQL stored procedures using two different techniques: return codes, and output parameters.

  1. Returning Values from Stored Procedures in SQL (this blog)
  2. Using Return Codes with Stored Procedures
  3. Using Output Parameters

This blog is part of a complete SQL tutorial. You can learn about the techniques used in this blog on our Advanced SQL training course.

Posted by Andrew Gould on 26 April 2013

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Returning Values from Stored Procedures in SQL

There are two techniques for returning values from a stored procedure: using return codes, and using output parameters. The main differences between these techniques are described in the table below:

Technique Description
Return code A stored procedure can return a single value using a return code. The data type of the value must be an integer (a whole number).
Output parameter A stored procedure can have many output parameters. An output parameter can use any data type.

Output parameters are more flexible than return codes but they are a little more fiddly to use. The rest of this blog series will show you how to use each of these techniques, starting with return codes.

 

  1. Returning Values from Stored Procedures in SQL (this blog)
  2. Using Return Codes with Stored Procedures
  3. Using Output Parameters
This blog has 0 threads Add post