Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Jobs that run during specific duration


Jobs that run during specific duration

Author
Message
Ryan007
Ryan007
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1618 Visits: 1595
Hi,
Do you have any handy script where I can get the list of jobs that ran during specified time period on a particular day.
For example, I need the job details that were running on 25th Sep 2013 between 2AM to 3AM. It is not necessary that job has to run from 2AM to 3 AM. The job may get completed/failed at 2.05 or the job might have started at 2.55. All the jobs that ran any time during this time span has to be listed.

Please help.

Ryan
//All our dreams can come true, if we have the courage to pursue them//
Alan.B
Alan.B
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2248 Visits: 7432
Below is a script that will get you information about all the jobs that ran between a two dates. I was not able to figure out how to get you between specific times (I only had a few minutes to put this together). Nonetheless, this should get you a closer to what you are looking for...


USE msdb

DECLARE @startDate date='9/1/2013',
@endDate date='10/1/2013';

WITH job_step_history AS
(
SELECT j.name AS job_name,
j.[description] AS job_description,
jh.step_id AS step,
jh.step_name,
js.command AS step_command,
CONVERT(datetime,CAST(jh.run_date AS char(8))) AS run_date,
left(replace(right(convert(varchar,dateadd(millisecond,jh.run_time,'00:00:00:000'),21),12),'.',':'),11) AS run_time,
jh.run_duration
FROM sysjobhistory jh
JOIN sysjobs j ON jh.job_id=j.job_id
LEFT JOIN sysjobsteps js ON jh.job_id=js.job_id AND jh.step_id=js.step_id
)
SELECT *
FROM job_step_history
WHERE run_date>=@startDate
AND run_date<=@endDate



-- Alan Burstein



Best practices for getting help on SQLServerCentral
Need to split a string? Try DelimitedSplit8K or DelimitedSplit8K_LEAD (SQL 2012+)
Need a pattern-based splitter? Try PatternSplitCM
Need to remove or replace those unwanted characters? Try PatExclude8K and PatReplace8K.

"I can't stress enough the importance of switching from a 'sequential files' mindset to 'set-based' thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code. " -- Itzek Ben-Gan 2001
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