Tuesday, March 20, 2012

package detect that instance is already running?

Folks,

I have a package scheduled to run every hour.

Users have asked if, in addition to the scheduled run, they can have it

so that they could dump a file into the input directory and then

kick-off the package immediately.

Problem is that things fail if they try to start the package when the scheduled instance of the package is still running.

Is there any way that the package could check to see if an instance if

itself is currently executing and refuse to execute if there IS an

instance running?

PJHow do users start the package?

If they use the same job that you run periodically, just start it manually regardless of schedule using sp_start_job, the single-instance behavior will be implemented by Agent (sp_start_job fails if the job is currently running).|||

You can use the MSMQ package to synchronize packages.

Kirk Haselden
Author "SQL Server Integration Services"

|||

Hi Michael,

Currently I'm just piloting this by getting users to go to SQL Server Agent in the management studio, right clicking on the job and selecting "Start Job at step.."

and I was going to give them a small winforms app to run which would do it.. I suppose I could get the app to execute a call to sp_start_job now and when it fails just inform em that the scheduled job is running...

By the way, if the scheduled time between runs is too short.. and the job is started again before the previous run has completed.. Agent will just fail the new instance ? Is that right?

Thanks

PJ

|||

By the way, if the scheduled time between runs is too short.. and the job is started again before the previous run has completed.. Agent will just fail the new instance ? Is that right?

Yes, I believe Agent always ensures only instance of a Job is ever running, so it will not run the second instance in this scenario.

No comments:

Post a Comment