Execute stored procedure with an Output parameter?

Return val from procedure

ALTER PROCEDURE testme @input  VARCHAR(10),
                       @output VARCHAR(20) output
AS
  BEGIN
      IF @input >= '1'
        BEGIN
            SET @output = 'i am back';

            RETURN;
        END
  END

DECLARE @get VARCHAR(20);

EXEC testme
  '1',
  @get output

SELECT @get 

The easy way is to right-click on the procedure in Sql Server Management Studio (SSMS), select 'Execute stored procedure..." and add values for the input parameters as prompted. SSMS will then generate the code to run the procedure in a new query window, and execute it for you. You can study the generated code to see how it is done.


Check this, where the first two parameters are input parameters and the 3rd is an Output parameter in the Procedure definition.

DECLARE @PK_Code INT;
EXEC USP_Validate_Login 'ID', 'PWD', @PK_Code OUTPUT
SELECT @PK_Code

you can do this :

declare @rowCount int
exec yourStoredProcedureName @outputparameterspOf = @rowCount output