Translate

Friday, 15 December 2017

sql : Execute stored procedure with output parameter

Create Procedure :

CREATE PROC USP_ExecuteProcedureWithOutputParameter

   @ApplicationNo  VARCHAR(8), 
   @status        VARCHAR(max) OUTPUT,
   @Remark        VARCHAR(max) OUTPUT   
) AS
BEGIN
SET @status='Application No:'+@ApplicationNo+',assign to status';
SET @Remark='Application No:'+@ApplicationNo+',assign to remark';
END



Execute Procedure 

DECLARE @return_value int,
    @status varchar(max),
    @Remark varchar(max)

EXEC @return_value = USP_ExecuteProcedureWithOutputParameter
@ApplicationNo = N'10001',
@status = @status OUTPUT,
@Remark = @Remark OUTPUT

SELECT @status as N'@status',
@Remark as N'@Remark';
SELECT 'Return Value' = @return_value;

No comments:

Post a Comment