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 proc in a new query window, and execute it for you. You can study the generated code to see how it is done.
you can do this :
declare @rowCount int
exec yourStoredProcedureName @outputparameterspOf = @rowCount output
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
Check this, Where first two parameters are input parameters and 3rd one is Output parameter in Procedure definition.
DECLARE @PK_Code INT;
EXEC USP_Validate_Login 'ID', 'PWD', @PK_Code OUTPUT
SELECT @PK_Code
Create Procedure [dbo].[test]
@Name varchar(100),
@ID int Output
As
Begin
SELECT @ID = UserID from tbl_UserMaster where Name = @Name
Return;
END
Declare @ID int
EXECUTE [dbo].[test] 'Abhishek',@ID OUTPUT
PRINT @ID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With