為給定的作業(yè)返回有關服務器的信息。
sp_help_jobserver [ @job_id = ] job_id |
[ @job_name = ] 'job_name'
[ , [ @show_last_run_details = ] show_last_run_details ]
[@job_id =] job_id
是為其返回信息的作業(yè)標識號。job_id 的數(shù)據(jù)類型為 uniqueidentifier,默認值為 NULL。
[@show_last_run_detail =] 'job_name'
是為其返回信息的作業(yè)名。job_name 的數(shù)據(jù)類型為 sysname,默認設置為 NULL。
說明 必須指定 job_id 或 job_name,但不能兩個都指定。
[@show_last_run_details =] show_last_run_details
表示上一次運行的執(zhí)行信息是否包含在結果集中。show_last_run_details 的數(shù)據(jù)類型為 tinyint,默認值為 0。0 表示不包括上一次的運行信息,但 1 包括。
0(成功)或 1(失?。?/P>
列名 | 數(shù)據(jù)類型 | 描述 |
---|---|---|
server_id | int | 目標服務器的標識號。 |
server_name | nvarchar(30) | 目標服務器的計算機名稱。 |
enlist_date | datetime | 將目標服務器登記到主服務器 (MSX) 的日期。 |
last_poll_date | datetime | 目標服務器上一次輪詢 MSX 的日期。 |
如果將 show_last_run_details 設置成 1,并且執(zhí)行 sp_help_jobserver,那么結果集中有下面這些額外的列。
列名 | 數(shù)據(jù)類型 | 描述 |
---|---|---|
last_run_date | Int | 在這個目標服務器上,作業(yè)上一次開始執(zhí)行的日期。 |
last_run_time | Int | 作業(yè)上一次在這臺服務器上開始執(zhí)行的時間。 |
last_run_duration | Int | 作業(yè)上一次在這臺目標服務器上運行所持續(xù)的時間(以秒為單位)。 |
last_outcome_message | nvarchar(1024) | 作業(yè)上一次在這個服務器上運行的結果: 0 = 失敗 |
sysadmin 固定服務器角色和 db_owner 固定數(shù)據(jù)庫角色在默認情況下有執(zhí)行此過程的權限,他們可以將權限授予其他用戶。
下面的示例返回有關 Archive Tables 作業(yè)的信息,其中包括上一次運行的信息。
USE msdb相關文章
EXEC sp_help_jobserver @job_name = 'Archive Tables',
@show_last_run_details = 1