|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SP Flow of ControlWhat happens when you run a SP inside of another SP?
My case: At the beginning of the SP I want to call another SP. If I do this will the called SP finish running before proceeding to run the rest of the code? Or do they run simultaneously? Thanks. Brian Shannon wrote:
> What happens when you run a SP inside of another SP? The "outer" SP will wait for the "inner" SP to complete before continuing...> > My case: > > At the beginning of the SP I want to call another SP. If I do this will the > called SP finish running before proceeding to run the rest of the code? Or > do they run simultaneously? > > Thanks. > > Your calling proc (top level proc) will wait for the called proc (inner
proc) to complete before continuing. Show quote "Brian Shannon" <brian.shan***@diamondjo.com> wrote in message news:%23Qyiqg4mGHA.1204@TK2MSFTNGP03.phx.gbl... > What happens when you run a SP inside of another SP? > > My case: > > At the beginning of the SP I want to call another SP. If I do this will > the called SP finish running before proceeding to run the rest of the > code? Or do they run simultaneously? > > Thanks. > If you want the second SP to run asynchronously, create a job and call
msdb..sp_start_job Otherwise, the first SP will wait for the second SP to finish before continuing on its task. Since the first SP is a unit, you wouldn't want to move to step 2 if it relied on the completion of step 1. SQL Server must step through the stored procedure step by step, because it has no way to know that you do not need to wait for a step to finish before moving on to the next step. Show quote "Brian Shannon" <brian.shan***@diamondjo.com> wrote in message news:%23Qyiqg4mGHA.1204@TK2MSFTNGP03.phx.gbl... > What happens when you run a SP inside of another SP? > > My case: > > At the beginning of the SP I want to call another SP. If I do this will > the called SP finish running before proceeding to run the rest of the > code? Or do they run simultaneously? > > Thanks. > |
|||||||||||||||||||||||