5 pts.
0
Q:
SQL Stored Procedure
Is there a way to call a child stored procedure form a parent sp but then immediately stop the parent?
ASKED: Apr 7 2009  3:29 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
47070 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Stored procedures have return values. In the parent sp check for a successful return value and end it in an if statement.

You can use a technique like this to do this.

CREATE PROCEDURE YourParentPRoc
AS
DECLARE @retValue INT

EXEC @retValue = YourChildProc
IF @retValue <> 0
return(0)

/*
More code goes after the return.
*/
END


This will run the child procedure and if the return value is not 0 it will stop the parent. Any code after the return does not get run if the @retValue <> 0 is true.
Last Answered: Apr 8 2009  8:40 PM GMT by Mrdenny   47070 pts.
Latest Contributors: Mshen   23525 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Carlosdl   29340 pts.  |   Apr 8 2009  12:00AM GMT

You might want to explain further what you need to accomplish.

 
0