dbTalk Databases Forums  

Prevent Job Run again

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Prevent Job Run again in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
hngo01
 
Posts: n/a

Default Prevent Job Run again - 05-04-2004 , 08:01 AM






Hi all, How do we prevent a job not to run more than once?
I have a job that only need to run one time a day. If I
accidentally run again then I have an issue. Duplicate
data. Thanks All

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Prevent Job Run again - 05-04-2004 , 08:19 AM






Don't schedule it to run more than once and then secure your system so that
no unauthorised users can start jobs (that they do not own).

You could add additional logic within you process or as another job step to
perform various checks.
You could query the sysjobhistory table to check when a job last ran for
example and if within a specified time period, raise an error halting the
job. A better method would be to design your processing such that it can
cope with multiple runs, or failing that checks for invalid data or other
such validations as can be determined by your business logic, and raiser
errors appropriately.




--
Darren Green
http://www.sqldts.com

"hngo01" <hngo01 (AT) hotmail (DOT) com> wrote

Quote:
Hi all, How do we prevent a job not to run more than once?
I have a job that only need to run one time a day. If I
accidentally run again then I have an issue. Duplicate
data. Thanks All



Reply With Quote
  #3  
Old   
Sanchan Sahai Saxena
 
Posts: n/a

Default RE: Prevent Job Run again - 05-12-2004 , 04:50 PM



There are a couple of things that you can do:

a) The best thing is to introduce some kind of checks in your process. You
mentioned that if the job runs more than once, you get duplicate data. What
you can do is - although it might be lengtheir - create an excel file with
all the data first and store it in a centralized location. Whenever, that
excel file is found to be already existing, make the job fail. This way,
you will not be able to put another set of duplicate data into your table,
even if you run the job manually.

b) If you want, you can write a Stored Procedure which also has a business
logic built into it. The Sp will not only run the job, but will also keep a
log file of the last time the job was run, along with the status -
failure/success. The next time when the Sp runs, it will first check the
log file and based on the status, can either run the job or cancel it.

Just some of the ways to counter your problem.


sanchans (AT) online (DOT) microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.