SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Server Job Scheduling


SQL Server Job Scheduling

Author
Message
Jim McCoy-259251
Jim McCoy-259251
SSC Journeyman
SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)

Group: General Forum Members
Points: 99 Visits: 261
Using DTS in 2000 I run a check for every second Thursday with the following code and set the 'job' to run every Thursday. If it is the right day the DTS continues otherwise it simply fails.

'*******************************************************
' Visual Basic ActiveX Script
'*******************************************************

' Test for the second week since a Job can only be set
' to work within a week. Prime with a run date.

Function Main()

Dim myDate
Dim oddEven

myDate = datediff("ww","8/10/2007",date())
oddEven = (myDate Mod 2)

if oddEven = 0 then

Main = DTSTaskExecResult_Success

else
Main = DTSTaskExecResult_failure
end if

End Function
Calvin E. Wrightsman
Calvin E. Wrightsman
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 11
One thing Peter failed to mention is that if you want to see lots of job history, be sure the job history log is big enough (Job System within SQL Server Agent properties).
Larry Aue
Larry Aue
SSC Veteran
SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)

Group: General Forum Members
Points: 223 Visits: 668
An easy way to do it is to have a first step that determines if today is the day the dw_job should run or the dm_job. You can cause the step to fail based on your criteria of choice (you can use a SQL step or ActiveX to do this). Then it's simply On Failure... load one, or On Succes.... load the other, in steps 2 and 3. Remember to quit on success and failure in 2, tho.. Wink



Wayne West
Wayne West
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3596 Visits: 3702
Rasool Omidakhsh (11/16/2007)
...I have to run this dm_job everyday. ... [dw_job] I have to run this job on every second thursday. ...

I don't see a problem with this, I would do it along these lines. dw_job has one schedule, occurs monthly, 2nd Thursday, runs once at 00:45. dm_job has five schedules, first one is weekly on Friday through Wednesday, the other schedules run 1st, 3rd, 4th, and last Thursday.

Unless I misunderstood your saying second Thursday and you meant every other Thursday, in which case do dw as Weekly, Every 2 Weeks, Starting 11/01/2007, then have dm_job doing the Thursday run Every 2 Weeks starting 11/08/2007. dm would still need the Friday-Wednesday schedule.

I think that would do it, but I could be wrong. Hehe

-----
Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson
Fox.David
Fox.David
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1
Were you able to complete the conditional scheduling for a SQL report?
Hem-586205
Hem-586205
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 24
Excellent article on Jobs.
vilas979
vilas979
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 0
Thanks for such good article
ruben 99661
ruben 99661
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 0
hi ,

i c your msg, and i have the same question. Can I perform this schedule jobs dynamically, with some conditional parameters ... ?? .. if you know something about it, please contact me ...
kas07
kas07
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 2
i have set up a job to run every five minutes.
If somehow the job takes more than five minutes in execution, will the sql scheduler run another instance of same job on five minutes cycle? when the last execution has not been completed?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search