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


sysjobhistory run_duration


sysjobhistory run_duration

Author
Message
SQLShark
SQLShark
Say Hey Kid
Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)

Group: General Forum Members
Points: 704 Visits: 244
Is this in seconds or ? It is not documented in BOL except for amount of time incurred in execution of a job. Thanks ...



David Benoit
David Benoit
SSCertifiable
SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)

Group: General Forum Members
Points: 7732 Visits: 3650
From SQL Server 2000 System Table Map (download from MS - search on systbl.chm)

"Elapsed time in the execution of the job or step in HHMMSS format."

Hope this helps.

David

David

@SQLTentmaker

“He is no fool who gives what he cannot keep to gain that which he cannot lose” - Jim Elliot
Antares686
Antares686
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: Moderators
Points: 26002 Visits: 785
It is based on time value sections.

Ex.

run_duration = HH:MM:SS
1 = 00:00:01
335 = 00:03:35
102456 = 10:24:56

Hops this helps.

"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)



SQLShark
SQLShark
Say Hey Kid
Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)

Group: General Forum Members
Points: 704 Visits: 244
Antares686 Thanks for your assistance on this matter, pochinej from www.sql-scripting.com



SQLShark
SQLShark
Say Hey Kid
Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)Say Hey Kid (704 reputation)

Group: General Forum Members
Points: 704 Visits: 244
DavidB Thanks also, I have the sytbl map and was working sql7 never know if its been changed but seems it has not been, Thanks...



MudLuck
MudLuck
Mr or Mrs. 500
Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)

Group: General Forum Members
Points: 525 Visits: 519
All,


I hate the formatting myself so thought I would share. This code was "borrowed" from Mike Pearson, thanks Mike...


As you can see it's all in the CASE.



select j.name,
case when h.step_name ='(Job outcome)' then '(Package Total)' else h.step_name end
, h.run_status,
CASE len(h.run_duration)
WHEN 1 THEN cast('00:00:0'
+ cast(h.run_duration as char) as char (8))
WHEN 2 THEN cast('00:00:'
+ cast(h.run_duration as char) as char (8))
WHEN 3 THEN cast('00:0'
+ Left(right(h.run_duration,3),1)
+':' + right(h.run_duration,2) as char (8))
WHEN 4 THEN cast('00:'
+ Left(right(h.run_duration,4),2)
+':' + right(h.run_duration,2) as char (8))
WHEN 5 THEN cast('0'
+ Left(right(h.run_duration,5),1)
+':' + Left(right(h.run_duration,4),2)
+':' + right(h.run_duration,2) as char (8))
WHEN 6 THEN cast(Left(right(h.run_duration,6),2)
+':' + Left(right(h.run_duration,4),2)
+':' + right(h.run_duration,2) as char (8))
END as 'Duration'
,h.run_duration
from dbo.sysjobs j
inner join dbo.sysjobhistory h
on j.job_id=h.job_id
where j.name like '%somejobName%'
order by j.name, h.step_name



JG-324908
JG-324908
SSC-Enthusiastic
SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)

Group: General Forum Members
Points: 130 Visits: 273
One more solution without case statement found in another forum,

SELECT stuff(stuff(replace(str(run_duration,6,0),' ','0'),3,0,':'),6,0,':') FROM sysJobHistory
techsboson
techsboson
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 577
Just curious in a hypothetical extreme situation but what if a job runs beyond a day like say for example 25 hours (or further more weeks, months, years, etc...)?...would it then still be represented as 25 hours or something like 1 day & 1 hour? Thanks in advance.
Elliott Whitlow
Elliott Whitlow
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23166 Visits: 5314
Yes, days can be included on the value. You can test this by creating a job that just sits for a day. I have a messy formula to calculate the value.

I like to deal with it in seconds so I use this:
((jh.run_duration/1000000)*86400) + (((jh.run_duration-((jh.run_duration/1000000)*1000000))/10000)*3600) + (((jh.run_duration-((jh.run_duration/10000)*10000))/100)*60) + (jh.run_duration-(jh.run_duration/100)*100)

Where jh is the jobhistory table..

CEWII
techsboson
techsboson
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 577
Thanks Elliott for the quick reply, much appreciated. So the further left/highest value that the run_duration field would contain would always be displayed in hours then?
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