Nested Stored Procedure (Return Value)

Results 1 to 3 of 3

Thread: Nested Stored Procedure (Return Value)

  1. #1
    Mauricio C. Guest

    Default Nested Stored Procedure (Return Value)

    &nbsp;<BR>Hello all, I&#039m calling a stored procedure (which returns an integer value) from another stored procedure. How do I get the returning value from the first proc??<BR><BR><BR>I&#039m doing it like this:<BR><BR>CREATE PROCEDURE sp_CallProc<BR><BR>AS<BR><BR> DECLARE @ReturnVal INT<BR><BR> SET @ReturnVal = EXECUTE sp_myFirstProc 3<BR><BR><BR><BR>myFirstProc takes 3 as param, and returns a value... in this particular case, the return value is 0. BUT when I do it like I show above, I get a sintax error (I am not even able to save the new stored proc.) The error msg is: Incorrect sintax near keyword EXECUTE. -- If I strip the "SET @ReturnVal =" then the Stored Proc gives me no probs, BUT.. how do I catch the returning value?

  2. #2
    Join Date
    Dec 1969

    Default RE: Nested Stored Procedure (Return Value)

    The only way that I&#039ve got this to work is by using an output parameter:<BR><BR>Create Procedure mySP<BR>(<BR>@in int, <BR>@out int OUTPUT<BR>)<BR>...<BR>SET @out = 0<BR><BR>You can then call this from another procedure like this:<BR><BR>DECLARE @retval INT<BR>exec mySP 3, @retval<BR><BR>and @retval will hold the value set in the first procedure.<BR><BR>Dunc

  3. #3
    Mauricio C. Guest

    Default RE: Thanks!

    &nbsp;<BR> it&#039s working, thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts