An example of a stored procedure with output parameters:
Alter procedure [dbo]. [GetCustomers]
(@ Rowcount INTOUTPUT)
AS
SELECT [CustomerID]
, [CompanyName]
, [ContactName]
, [ContactTitle]
, [Address]
, [City]
, [Region]
, [PostalCode]
, [Country]
, [Phone]
, [Fax]
FROM [Northwind]. [dbo]. [MERs]
SET @ rowcount = @ rowcount
Then, a stored procedure with a returned value is returned.
Alter procedure [dbo]. [GetCustomers]
AS
SELECT [CustomerID]
, [CompanyName]
, [ContactName]
, [ContactTitle]
, [Address]
, [City]
, [Region]
, [PostalCode]
, [Country]
, [Phone]
, [Fax]
FROM [Northwind]. [dbo]. [MERs]
RETURN @ rowcount
So, how can I call this stored procedure in another stored procedure and receive its output parameters or return value parameters?
The following is an example of receiving output parameters.
DECLARE @ count INT
EXECUTE GetCustomers @ count OUTPUT
PRINT @ count
The following is an example of receiving return value parameters.
DECLARE @ count INT
EXECUTE @ count = GetCustomers
PRINT @ count