none
Executing Multiple Stored Procedure RRS feed

  • Question

  • Hi guys,

    Please if one has a stored procedure that execute multiple other stored procedure:

    e.g.

    exec usp_A

    exec usp_B

    exec usp_C

    How does the execution work, will the 3 run in sequentially and in parallel. If they run sequentially, will SQL wait for usp_A to finish executing before running usp_B and then usp_C.

    If it doesnt, what is the best way to make that happened. Cos I want usp_B to start executing only after usp_A has completed and then for usp_C to start after usp_B has finished.


    me

    Tuesday, February 12, 2019 5:43 PM

Answers

  • Based on the information in this post ( https://social.msdn.microsoft.com/Forums/sqlserver/en-US/7f1bea3e-0feb-43e1-aaaf-0cf36253f264/how-to-execute-multiple-sql-statements-in-parallel-?forum=transactsql ), SQL Server will perform serial execution by default.

    I cannot vouch for the accuracy of this information so I recommend testing.

    • Proposed as answer by Javid Doe Tuesday, February 12, 2019 6:38 PM
    • Marked as answer by lilutchay Tuesday, February 12, 2019 9:25 PM
    Tuesday, February 12, 2019 6:37 PM
  • SQL will definitely run usp_A to completion and start usp_B after usp_A finishes.  In the same usp_C will wait for usp_B to finish.

    Tom

    • Marked as answer by lilutchay Tuesday, February 12, 2019 9:25 PM
    Tuesday, February 12, 2019 8:15 PM

All replies

  • Based on the information in this post ( https://social.msdn.microsoft.com/Forums/sqlserver/en-US/7f1bea3e-0feb-43e1-aaaf-0cf36253f264/how-to-execute-multiple-sql-statements-in-parallel-?forum=transactsql ), SQL Server will perform serial execution by default.

    I cannot vouch for the accuracy of this information so I recommend testing.

    • Proposed as answer by Javid Doe Tuesday, February 12, 2019 6:38 PM
    • Marked as answer by lilutchay Tuesday, February 12, 2019 9:25 PM
    Tuesday, February 12, 2019 6:37 PM
  • SQL will definitely run usp_A to completion and start usp_B after usp_A finishes.  In the same usp_C will wait for usp_B to finish.

    Tom

    • Marked as answer by lilutchay Tuesday, February 12, 2019 9:25 PM
    Tuesday, February 12, 2019 8:15 PM