Check return value from stored procedure

I have two stored procedures: ProcA and ProcB. I would like ProcA to execute ProcB and ask ProcB to return the integer back to ProcA.

My preference would be to use the instruction RETURNin ProcB, but I will use the option OUTPUTif this is my only choice.

Yes, stackoverflow has similar questions. But not yet find one that will compile using Microsoft SQL Server 2008.

+3
source share
1 answer
CREATE PROC dbo.ProcB
(@pb int)
AS
RETURN 2* @pb /*Double it*/

GO

CREATE PROC dbo.ProcA
(@pa int)
AS

DECLARE @ret INT
EXEC @ret = dbo.ProcB @pb = @pa
SELECT @ret as doubled

GO

EXEC dbo.ProcA @pa = 10

Returns

doubled
-----------
20
+3
source

All Articles