There is a simple way to implement this without the Agent, using Service Broker.
The basic Idea is that we can use Service broker instead of the Agent, like we do with SQL EXPRESS maintenance. This is how I backup all my client's SQL EXPRESS databases :-)
* i found this link for example (I did not read it all but it look like a tutorial of the issue that I am talking about):
http://www.sqlteam.com/article/scheduling-jobs-in-sql-server-express-2
Now that we know how to use Service Broker in order to Schedule tasks, we can disugn this
procedure
Let's assume that we have 3 steps that need to be execute in ordered way, but only step 2 can be execute in parallel,
and we need to execute it 4 times, next only when all the 4 times of step 3 end we need to execute step 3 once. Our time line will be:
------- time line ----
Step 1 start
Step 1 End -> activate step 2 four times (Service Broker work
synchronicity on all message, we just need to activate 4 messages)
Step 2 Start first
Step 2 start second time
Step 2 start third time
Step 2 start fourth time
Step 2 end one after the other...
each time step 2 end we check if this is the last execution of step 2
Only when step 2 ended 4 times then we activate Step 3 which start
------- ----
The implementation:
In order to use the service broker we created table with all the tasts that we need to execute. We will have one column for "active"
1 or 0. At the start we mark only step 1 as active. In step 1 in the end of the task we add simple query that activate (update the table) all the 4 tasks of step 2, so now afyter step 1 end it start step 2 four times parallel. We store a simple parameter in
table or any pother way that we want that hold the number of "step 2" processes ended. In the end of step 2 (each executing of step 2) we check what is the value of the parameter. if the value is 3 then we finished the fourth execution now
=> therefore we will activate step 4, if the value is less then 3 then we update this parameter and add 1 (dont forget to lock the table that store the parameter during the check-> update procedure)
that is all the idea....
I hope you can understand my poor English :-(
I need to go, and I did not have time to check with Google translator
* it worked for me in practice on production in the past (on SQL EXPRESS but there is no reason
not to use this procedure on other versions as well). In my case It is a bit more complex since "step 3" need information from all the parallel execution of step 2, therefore i store this info in a simple table, and step 3 use it.