Using Output Parameters
If a calling batch passes a variable as a parameter to a stored procedure and that parameter is modified inside the procedure, the modifications are not passed to the calling batch unless they are defined as OUTPUT
parameters. To define a parameter as an OUTPUT parameter, you need to specify the keyword OUTPUT
in the parameter definition when creating the procedure. The following example shows a stored procedure that accepts two parameters, one of which is defined as an output parameter:
IF EXISTS ( SELECT * FROM sys.procedures WHERE schema_id= schema_id('dbo') AND name = N'product_sales') DROP PROCEDURE dbo.product_salesGOCREATE PROC product_sales@ProductID ...
Get Microsoft SQL Server 2014 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.