SQL Server ジョブ一覧、ジョブの実行結果をクエリーで
2017.04.23 13:48
-- ジョブ一覧取得
use [msdb]
SELECT
name as JOB_NAME
,replace(description,'使用できる説明はありません。','') as JOB_NOTE
,case enabled when 1 then '有効' else '無効' end as '使用有無'
FROM dbo.sysjobs_view
-- WHERE enabled = 1 -- 有効
order by name;
-- ジョブの実行結果を確認
select b.name,a.* from sysjobhistory a
join (
select * from sysjobs
where name = 'ジョブ名' -- where name like '%MY_JOB_%'
and enabled = 1
) b on (a.job_id = b.job_id)
order by a.job_id, a.step_id;