Hello...
I want to write a query that will list for me the name, date and time of
jobs that ran from the previous hour. I am using SQL Server 2000.
Thank you,
Brett>> ...a query that will list for me the name, date and time of jobs that ran
The data you are looking for is available in msdb..sysjobhistory table. You
can do:
SELECT job_name, run_time
FROM ( SELECT CAST( CAST( run_date AS CHAR( 9 ) ) +
STUFF( STUFF( RIGHT( REPLICATE( '0', 6 ) +
CAST( run_time AS VARCHAR ), 6 ) , 3, 0 , ':' ) , 6, 0 ,
':' )
AS DATETIME ),
( SELECT name
FROM msdb..sysjobs s2
WHERE s2.job_id = s1.job_id )
FROM msdb..sysjobhistory s1 ) D ( run_time, job_name )
WHERE run_time >= DATEADD( hour, -1, CURRENT_TIMESTAMP ) ;
Perhaps, someone else might post a more simplified string format routine.
Anith
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment