Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Execute stored procedures at the same time

Author  Topic 

NickStan
Starting Member

36 Posts

Posted - 2012-03-22 : 11:13:56
Hello all

I am working on SQL 2008 R2.

I have about 40 stored procedures that are not related to each other that import data from another database.

All of these stored procedures will be executed from 1 main procedure.
How do I get all of these procedure to run at the same time instead of waiting for the previous procedure to complete?

I do not want to create an job for each procedure I want everything to be contained in 1 procedure if possible.

The reason why I want these to run at the same time is to decrease the query - or will this not have an effect or help?

Thanks

Nick

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-03-22 : 11:27:47
create a job that fires stored proc 1 as the first step. Then fires proc2 as step 2. repeat for as many procs as you have. 40 steps, 1 job.









How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-03-22 : 11:28:01
Stored procedures run sequentially, so you can't run in parallel using that mechanism.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-22 : 13:40:03
Create 1 Job and script it out

Clone the script 40 times and change the sproc name, the compile the jobs

Use sp_start_job to launch them asynchronously

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -