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


Need help in calculating the RUNTIME of my Job's ETL


Need help in calculating the RUNTIME of my Job's ETL

Author
Message
Mac1986
Mac1986
SSC Veteran
SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)

Group: General Forum Members
Points: 278 Visits: 787
Hi All,
I have 58 sequentially run jobs as part of our Database ETL. So, I took the start time of the 1st job and EndTime of 58th Job to calculate the totla Run time of the ETL.

I'm using the following TSQL logic to get the time difference between the jobs but if the ETL is > than 24 hours, I'm not getting the correct difference in hours. Please suggest.

Need to calculate the difference between 2012-12-16 20:57:01.293 and 2012-12-18 01:26:57.573

When I use: DATEDIFF(HH,Start.WorkQueueStartWorkDate,Finish.WorkQueueEndWorkDate) RunTimeInHours
I get 20 Hrs



When I use convert(varchar,(Finish.WorkQueueEndWorkDate - Start.WorkQueueStartWorkDate),108) RunTime 
I get 04:29:56



Please help me getting the correct difference as Runtime.
Mac1986
Mac1986
SSC Veteran
SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)SSC Veteran (278 reputation)

Group: General Forum Members
Points: 278 Visits: 787
Never mind I figure out a way to get the right Datetime...

convert(varchar(5),DateDiff(s, Start.WorkQueueStartWorkDate,Finish.WorkQueueEndWorkDate)/3600)+':'+convert(varchar(5),DateDiff(s, Start.WorkQueueStartWorkDate,Finish.WorkQueueEndWorkDate)%3600/60)+':'+convert(varchar(5),(DateDiff(s, Start.WorkQueueStartWorkDate,Finish.WorkQueueEndWorkDate)%60)) as [hh:mm:ss]


Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45080 Visits: 39912
Mac1986 (12/22/2012)
I'm using the following TSQL logic to get the time difference between the jobs but if the ETL is > than 24 hours...


... then I'd have to say that you might have a bit of a performance problem.

If it were me, I'd add another timer to measure the duration of each of the 58 jobs and the fix the job that's taking the longest and maybe continue from there.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
ScottPletcher
ScottPletcher
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3944 Visits: 6680

SELECT
CAST(DATEDIFF(SECOND, Start.WorkQueueStartWorkDate, Finish.WorkQueueEndWorkDate) / 3600 AS varchar(3)) +
RIGHT(CONVERT(char(8), Finish.WorkQueueEndWorkDate - Start.WorkQueueStartWorkDate, 8), 6)
from (
select CAST('20121216 20:57:01.293' AS datetime) AS WorkQueueStartWorkDate
) AS start
cross join (
select CAST('20121218 01:26:57.573' AS datetime) AS WorkQueueEndWorkDate
) as finish




SQL DBA,SQL Server MVP('07, '08, '09)

Prosecutor James Blackburn, in closing argument in the "Fatal Vision" murders trial: "If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them."
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