New Post has been published on Varinder Sandhu 's Blog
New Post has been published on http://www.varindersandhu.in/2011/11/17/sql-server-stored-procedure-with-output-parameters/
SQL Server - Stored Procedure with Output Parameters
In SQL Server, there are two ways with we can pass parameters to procedures.
These types of parameters are used to send values to stored procedures.
<!-- google_ad_client = "pub-2404605494811633"; google_alternate_color = "FFFFFF"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "FFFFFF"; google_color_link = "0000FF"; google_color_bg = "FFFFFF"; google_color_text = "000000"; google_color_url = "008000"; google_ui_features = "rc:6"; //-->
These types of parameters are used to get values from stored procedures. This is similar to a return type in functions.
In this post we will try to understand how stored procedure returns the parameter
-- Create a table CREATE TABLE myTable ( ID INT Identity(1,1), Name VARCHAR(20) ) -- Now Create a Stored Procedure with the OUTPUT parameter CREATE PROCEDURE my_sp ( @name VARCHAR(20), @id_out INT OUTPUT ) AS BEGIN INSERT INTO myTable VALUES (@name) SELECT @id_out = Scope_Identity () END GO
Stored Procedure with Output Parameters
Similarly, for the second row
Stored Procedure with Output Parameters
Stored Procedure with Output Parameters
Similarly you can get values from stored procedures as you need or required. Hope this post helps you to understand the OUTPut parameters.