Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Job History with Timeline Expand / Collapse
Author
Message
Posted Sunday, April 05, 2009 5:44 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, October 30, 2013 6:17 AM
Points: 121, Visits: 319
Comments posted to this topic are about the item Job History with Timeline


Post #690677
Posted Wednesday, May 13, 2009 7:10 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, February 04, 2014 9:35 AM
Points: 1,277, Visits: 1,612
Thanks, I like it!

I did make a couple of minor changes. Our server names are >10 characters and I like to see the run date and run time in descending order.

SET DATEFORMAT dmy
SELECT
convert(varchar(20),his.server) as Server, -- Increased to 20 characters
convert(varchar(30),job.name) AS job_name,
CASE his.run_status
WHEN 0 THEN 'Failed'
WHEN 1 THEN 'Succeeded'
ELSE '???'
END as run_status,
convert(varchar(4),run_duration/10000) + ':' + convert(varchar(4),run_duration/100%100) + ':' + convert(varchar(4),run_duration%100) as run_duration,
convert(datetime, convert(varchar(10),run_date%100) + '/' + convert(varchar(10),run_date/100%100) + '/' + convert(varchar(10),run_date/10000) + ' ' + convert(varchar(4),run_time/10000) + ':' + convert(varchar(4),run_time/100%100) + ':' + convert(varchar(4),run_time%100)) as start_date,
datediff(mi, getdate()-1, convert(datetime, convert(varchar(10),run_date%100) + '/' + convert(varchar(10),run_date/100%100) + '/' + convert(varchar(10),run_date/10000) + ' ' + convert(varchar(4),run_time/10000) + ':' + convert(varchar(4),run_time/100%100) + ':' + convert(varchar(4),run_time%100))) as LeadingMinutes,
isnull(nullif(convert(int,(run_duration/10000 * 60) + (run_duration/100%100) + (ceiling(run_duration%100/60.0))),0),1) as DurationMinutes,
REPLICATE(' ', datediff(mi, getdate()-1, convert(datetime, convert(varchar(10),run_date%100) + '/' + convert(varchar(10),run_date/100%100) + '/' + convert(varchar(10),run_date/10000) + ' ' + convert(varchar(4),run_time/10000) + ':' + convert(varchar(4),run_time/100%100) + ':' + convert(varchar(4),run_time%100)))) +
REPLICATE('x', isnull(nullif(convert(int,(run_duration/10000 * 60) + (run_duration/100%100) + (ceiling(run_duration%100/60.0))),0),1)) as DurationTimeline,
his.message
FROM
msdb.dbo.sysjobhistory his
INNER JOIN msdb.dbo.sysjobs job ON his.job_id = job.job_id
WHERE
convert(datetime, convert(varchar(10),run_date%100) + '/' + convert(varchar(10),run_date/100%100) + '/' + convert(varchar(10),run_date/10000) + ' ' + convert(varchar(4),run_time/10000) + ':' + convert(varchar(4),run_time/100%100) + ':' + convert(varchar(4),run_time%100)) between getdate()-1 and getdate()
and step_id = 0
ORDER BY
his.server,
his.run_date DESC, -- Added DESC
his.run_time DESC, -- Added DESC
job.name



Post #715932
Posted Tuesday, June 01, 2010 1:11 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, April 17, 2014 12:04 PM
Points: 311, Visits: 1,080
Nicely done! I like the graph too.

I was looking at the graph and thought shouldn't it reset back to left side of the "Duration Timeline" once the the next day's jobs are executed? Currently it looks like (from the graph) that the times of the jobs are changing.

Just a thought.




Post #930948
Posted Wednesday, June 02, 2010 9:55 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, August 19, 2013 11:53 AM
Points: 17, Visits: 559
I'm a newbie. can you explain a little more about leading minutes and duration timeline column? I don't understand. What spaces are you talking about? Please help me to understand.
Post #931467
Posted Wednesday, June 02, 2010 12:53 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, October 30, 2013 6:17 AM
Points: 121, Visits: 319
Hi amc. It works like a bar chart. For every minute a job is running, an 'X' is printed. For every minute it is not running, a space is printed. You can compare the lines to see when jobs are running at the same time. So, if you have one row returned where the 'X's line up vertically with the lines above or below it, then it means the jobs were running concurrently.

Hope that helps,

Martin



Post #931607
Posted Wednesday, June 02, 2010 1:06 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, August 19, 2013 11:53 AM
Points: 17, Visits: 559
Oh--Ok, I got it now. thank you! Becasue I really like this query.
Uh, one more thing...explain LeadingMinutes, please.
Post #931618
Posted Tuesday, January 10, 2012 7:29 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: 2 days ago @ 1:05 PM
Points: 304, Visits: 1,171
Nice Script ...
I would like to know whats mean of XX in result.
i can not see last week's jobs result . like today tue morning i am running this script it showing me result on 2011-01-09 and 2011-01-10 what if i want to see results before this duration?
Thanks


Aim to inspire rather than to teach.
SQL Server DBA
Post #1233209
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse