February 6, 2014 at 6:51 am
Hi,
I have a job having two steps. I want run step1 every 30mins.Second step need to be run once in a day. Is it Possible?
February 6, 2014 at 6:56 am
make step 2 test for a specific time window as part of it's process.
i start a trace @7am if it's not running, and turn it off at 5pm for example:
--###############################################################################################
--startup logic if required.
--###############################################################################################
IF EXISTS (SELECT * FROM master.sys.traces WHERE PATH LIKE '%MyDMLTrace%' AND STATUS = 0)
AND (DATEDIFF(hh,DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0),GETDATE()) = 7) --7am, not started?
BEGIN
EXEC sp_trace_setstatus @TRACEID, 1 ---start trace
END
Lowell
February 7, 2014 at 11:29 am
EDIT: As the OP didn't mention any dependency, I agree with the other posters - create two jobs if the steps are independent of each other.
One option (if and only if step 2 is dependent on step 1):
Step 2's process should log when it was last run/every time it runs.
Step 2 then first checks to see if it's run this day/within the last 24 hours, and if not, it runs. This will cover you in case the job's doesn't run every 30 minutes for awhile (SQL Server patch + reboot meant services were down during one or more scheduled interval, for example).
February 11, 2014 at 2:10 am
Why don't you just create two jobs?
February 11, 2014 at 5:43 am
I'm just throwing this to table so I could be completely wrong here ...experts would be able to put insight ...I think it be done using a batch file .. a batch file will have a code which will call the first step from the job every half an hour and the query to call second step will be executed only once at specific time of server.
Job setting could be set as follows
Job step 1 : On success ..quit job with success
On failure --- Quit job reporting failure
Job step 2 : On success ..quit job with success
On failure --- Quit job reporting failure
February 12, 2014 at 7:09 am
crmitchell (2/11/2014)
Why don't you just create two jobs?
+1, keep it simple.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply