2012年1月16日 星期一

select from sp_help_job

--查看job目前執行狀況
select 
 name
,last_run_date as lastdt
,last_run_time as lasttm
,case last_run_outcome
 when 0 then 'Failed.'
 when 1 then 'Succeeded.'
 when 3 then 'Canceled.'
 when 5 then 'Unknown'
 else 'others' end as lastOutcome
,case current_execution_status
 when 1 then 'Executing.'
 when 2 then 'Waiting for thread.'
 when 3 then 'Between retries.'
 when 4 then 'Idle.'
 when 5 then 'Suspended'
 when 7 then 'Performing completion actions.'
 else 'others.' end as currentStatus
from openrowset ('SQLNCLI', 'Database=msdb;Uid=sa;Pwd=xxxx;','set fmtonly off;exec sp_help_job')
where name like '%yourJobName%'




參考database journal 文章Detecting The State of a SQL Server Agent Job的欄位說明

沒有留言:

張貼留言

IIS 網站無法下載中文檔名檔案因為取消高位元字元

 網址+中文檔案名稱方式下載檔案顯示 404 - 找不到檔案或目錄。 但英數字檔案名稱則可下載。 因為設定GCB IIS,其中1項 將高位元字元預設取消勾選了。 27 TWGCB-04-014-0028 要求篩選與其他限制模組 允許高位元字元 這項原則設定決定查詢...