<p id="q3ghu"></p>

<button id="q3ghu"><listing id="q3ghu"><acronym id="q3ghu"></acronym></listing></button>
<button id="q3ghu"><dd id="q3ghu"></dd></button>

<p id="q3ghu"><listing id="q3ghu"><acronym id="q3ghu"></acronym></listing></p>
<p id="q3ghu"></p><p id="q3ghu"></p>
<acronym id="q3ghu"><dd id="q3ghu"><u id="q3ghu"></u></dd></acronym>

<acronym id="q3ghu"></acronym><p id="q3ghu"></p>
環球網校是美國納斯達克上市企業歡聚時代(NASDAQ:YY)旗下品牌 | 住房和城鄉建設部 建筑人才培訓合作單位
您現在的位置在: > 計算機類 > 計算機等級考試 > 考試輔導 >

計算機等級考試輔導:SQL中JOB的運行狀態

2010-07-02 來源:互聯網 作者:第一考試網

  一, 查看是否正在運行
  Declare @Job_ID as UNIQUEIDENTIFIER
  select @Job_ID =Job_ID from msdb.dbo.sysjobs where name = 'James_Test'
  Exec master..sp_MSget_jobstate @Job_ID
  返回值為 1 - 正在運行
  4 - 表示完成(成功或失敗)
  二, 檢查執的結果狀態
  查看 SQL Server 作業(job) 運行成功與否、還是取消等狀態信息,以及作業最后一次運行持續時間、出錯信息提示等。DBA 可以周期性地調度該 SQL 腳本,在 SQL Server 作業失敗時候得到及時提醒。此 SQL 腳本適用于 SQL Server 2000 & 2005。
  -- author : p.c.w.l
  -- source : www.examda.com
  -- create : 2008-11-27
  -- descr : a simple sql script to view sql server jobs run status
  select category = jc.name,
  category_id = jc.category_id,
  job_name = j.name,
  job_enabled = j.enabled,
  last_run_time = cast(js.last_run_date as varchar(10)) + '-' + cast(js.last_run_time as varchar(10)),
  last_run_duration = js.last_run_duration, #
  last_run_status = js.last_run_outcome,
  last_run_msg = js.last_outcome_message + cast(nullif(js.last_run_outcome,1) as varchar(2)),
  job_created = j.date_created,
  job_modified = j.date_modified
  from msdb.dbo.sysjobs j
  inner join msdb.dbo.sysjobservers js
  on j.job_id = js.job_id
  inner join msdb.dbo.syscategories jc
  on j.category_id = jc.category_id
  where j.enabled = 1
  and js.last_run_outcome in (0,1,3,5) -- 0:Fail 1:Succ 3:Cancel 5:First run
  and jc.category_id not between 10 and 20 -- repl
  三, 查看歷史情況
  
select run_status,a.run_time, a.* from msdb.dbo.sysjobhistory a inner join msdb.dbo.sysjobs b on a.job_id=b.job_id where b.name='作業名'作業的執行狀態run_status: 0 = 失敗1 = 成功2 = 重試3 = 取消4 = 正在進行。

#

責編:小魚 返回頂部  打印

關于我們聯系我們友情鏈接網站聲明網站地圖廣告服務幫助中心
337p中国尤物人体

<p id="q3ghu"></p>

<button id="q3ghu"><listing id="q3ghu"><acronym id="q3ghu"></acronym></listing></button>
<button id="q3ghu"><dd id="q3ghu"></dd></button>

<p id="q3ghu"><listing id="q3ghu"><acronym id="q3ghu"></acronym></listing></p>
<p id="q3ghu"></p><p id="q3ghu"></p>
<acronym id="q3ghu"><dd id="q3ghu"><u id="q3ghu"></u></dd></acronym>

<acronym id="q3ghu"></acronym><p id="q3ghu"></p>