Tuesday, 29 March 2016

MSSQL - Declare OUTPUT parameters inside Stored Procedure


Watch this example on YouTube:

1. Here is my first sp:
CREATE PROCEDURE [dbo].[TestOutput_Procedure1]
    @Success int = 0 Output
AS
BEGIN
    SET NOCOUNT ON;

    SET @Success = 1;
    Return @Success;
END

2. Second one
CREATE PROCEDURE [dbo].[TestOutput_Procedure2]
AS
BEGIN
    SET NOCOUNT ON;

    Declare @Success int = 0;
    Exec TestOutput_Procedure1 @Success OUTPUT;
    Select @Success;
END

3. Test
Exec TestOutput_Procedure2;

No comments:

Post a Comment