select
job_id, name,
step_id, step_name,
subsystem, command,
database_name,
last_run_outcome, last_run_date,
(substring(last_run_time, 1, 2) + ':' + substring(last_run_time, 3, 2) + ':' + substring(last_run_time, 5, 2)) as last_run_time,
(substring(last_run_duration, 1, 2) + ':' + substring(last_run_duration, 3, 2) + ':' + substring(last_run_duration, 5, 2)) as
last_run_duration,
last_run_retries,
sMessage
from (
select a.job_id, name, step_id, step_name,
subsystem, command,
database_name,
(case last_run_outcome when 0 then '실패'
when 1 then '성공' else '알수없음' end) as last_run_outcome,
last_run_date,
right('S000000' + convert(varchar(8), last_run_time), 6) as last_run_time,
right('S000000' + convert(varchar(8), last_run_duration),
6) as
last_run_duration,
last_run_retries,
(case when
last_run_outcome = 0 then
(
select
top 1 [message]
from msdb.dbo.sysjobhistory
where job_id = a.job_id and run_date = b.last_run_date and run_time = b.last_run_time
) else '' end) as sMessage
from msdb.dbo.sysjobs a
left
join msdb.dbo.sysjobsteps b on a.job_id = b.job_id
where enabled
= 1
) as O
order by name, step_id
'Brain Trainning > DataBase' 카테고리의 다른 글
Brad M. McGehee SQL Presentations (0) | 2010.09.08 |
---|---|
유용한 SQL Poster (0) | 2010.08.26 |
Backup 용 Script (0) | 2010.08.24 |
MBSA Command Line Tool (0) | 2010.08.22 |
MBSA Offline Scan file (0) | 2010.08.22 |