Agent History5:Job Activity Monitor 查看Job History的代码

可以使用这两个SP快速查看Job执行的状态,而不用打开Monitory。

1,查看Job 执行结果

exec [msdb].[dbo].[sp_help_job]

msdb中该dbo.sp_help_job的参数如下:

ALTER PROCEDURE [dbo].[sp_help_job]
  -- Individual job parameters
  @job_id                     UNIQUEIDENTIFIER = NULL,  -- If provided should NOT also provide job_name
  @job_name                   sysname          = NULL,  -- If provided should NOT also provide job_id
  @job_aspect                 VARCHAR(9)       = NULL,  -- JOB, STEPS, SCHEDULES, TARGETS or ALL
  -- Job set parameters
  @job_type                   VARCHAR(12)      = NULL,  -- LOCAL or MULTI-SERVER
  @owner_login_name           sysname          = NULL,
  @subsystem                  NVARCHAR(40)     = NULL,
  @category_name              sysname          = NULL,
  @enabled                    TINYINT          = NULL,
  @execution_status           INT              = NULL,  -- 1 = Executing, 2 = Waiting For Thread, 3 = Between Retries, 4 = Idle, 5 = Suspended, 6 = [obsolete], 7 = PerformingCompletionActions
  @date_comparator            CHAR(1)          = NULL,  -- >, < or =
  @date_created               DATETIME         = NULL,
  @date_last_modified         DATETIME         = NULL,
  @description                NVARCHAR(512)    = NULL   -- We do a LIKE on this so it can include wildcards
AS

2,查看Job Step

declare @tmp_sp_help_jobhistory table
(
    instance_id int null,
    job_id uniqueidentifier null,
    job_name sysname null,
    step_id int null,
    step_name sysname null,
    sql_message_id int null,
    sql_severity int null,
    message nvarchar(4000) null,
    run_status int null,
    run_date int null,
    run_time int null,
    run_duration int null,
    operator_emailed sysname null,
    operator_netsent sysname null,
    operator_paged sysname null,
    retries_attempted int null,
    server sysname null
)

insert into @tmp_sp_help_jobhistory
exec msdb.dbo.sp_help_jobhistory
    @job_id = ‘af5eb80e-ef1e-4f2c-adb3-a45bfc2c3f57‘,
    @mode=‘FULL‘ 

SELECT
    tshj.instance_id AS [InstanceID],
    tshj.sql_message_id AS [SqlMessageID],
    tshj.message AS [Message],
    tshj.step_id AS [StepID],
    tshj.step_name AS [StepName],
    tshj.sql_severity AS [SqlSeverity],
    tshj.job_id AS [JobID],
    tshj.job_name AS [JobName],
    tshj.run_status AS [RunStatus],
    CASE tshj.run_date WHEN 0 THEN NULL ELSE
    convert(datetime,
            stuff(stuff(cast(tshj.run_date as nchar(8)), 7, 0, ‘-‘), 5, 0, ‘-‘) + N‘ ‘ +
            stuff(stuff(substring(cast(1000000 + tshj.run_time as nchar(7)), 2, 6), 5, 0, ‘:‘), 3, 0, ‘:‘),
            120) END AS [RunDate],
    tshj.run_duration AS [RunDuration],
    tshj.operator_emailed AS [OperatorEmailed],
    tshj.operator_netsent AS [OperatorNetsent],
    tshj.operator_paged AS [OperatorPaged],
    tshj.retries_attempted AS [RetriesAttempted],
    tshj.server AS [Server],
    getdate() as [CurrentDate]
FROM @tmp_sp_help_jobhistory as tshj
ORDER BY [InstanceID] ASC

msdb中 dbo.sp_help_jobhistory的参数如下:

ALTER PROCEDURE [dbo].[sp_help_jobhistory]
  @job_id               UNIQUEIDENTIFIER = NULL,
  @job_name             sysname          = NULL,
  @step_id              INT              = NULL,
  @sql_message_id       INT              = NULL,
  @sql_severity         INT              = NULL,
  @start_run_date       INT              = NULL,     -- YYYYMMDD
  @end_run_date         INT              = NULL,     -- YYYYMMDD
  @start_run_time       INT              = NULL,     -- HHMMSS
  @end_run_time         INT              = NULL,     -- HHMMSS
  @minimum_run_duration INT              = NULL,     -- HHMMSS
  @run_status           INT              = NULL,     -- SQLAGENT_EXEC_X code
  @minimum_retries      INT              = NULL,
  @oldest_first         INT              = 0,        -- Or 1
  @server               sysname          = NULL,
  @mode                 VARCHAR(7)       = ‘SUMMARY‘ -- Or ‘FULL‘ or ‘SEM‘
时间: 2024-11-10 21:04:10

Agent History5:Job Activity Monitor 查看Job History的代码的相关文章

使用performance monitor 查看 每一个cpu core的cpu time

使用performance monitor 查看 每一个cpu core的cpu time: 打开performance monitor,添加 counter 如下 运行一段cpu bound 的代码: cpu time瞬间彪到100% 结束代码运行.

C# 如何查看源程序的IL代码

1.打开microsoft  visual  studio  2008  /  visual  studio  tools /  visual  studio  2008 命令提示  ,并输入ildasm .如下图所示: 2.按enter键,打开IL DASM 窗口,如下图所示: 3.单击 文件 / 打开,打开编译好的.exe文件,即可查看该代码的IL代码 例如:通过visual  studio  2008 命令提示 查看如下源程序的IL代码. using System;using System

使用Xcode 查看objective-C的汇编代码

Xcode自带将某一个源文件转化成汇编的功能,如图: 汇编的部分代码如下: # Assembly output for assemble.c # Generated at 2:29:34 下午 on 星期一, 八月 18, 2014 # Using Debug configuration, x86_64 architecture for dataStruct target of dataStruct project .section __TEXT,__text,regular,pure_inst

沉淀再出发:如何在eclipse中查看java的核心代码

沉淀再出发:如何在eclipse中查看java的核心代码 一.前言   很多时候我们在eclipse中按F3键打算查看某一个系统类的定义的时候,总是弹出找不到类这样的界面,这里我们把核心对应的代码加进去就可以了. 二.解决办法  2.1.打开配置    首先我们打开windows->preferences->java->install jres,在弹出的界面中选中并编辑:      然后选中rt.jar包,增加依赖: 2.2.添加代码文件 那么这个依赖在哪里呢,其实我们仔细查找就会发现,

spark 查看 job history 日志

SPARK_HOME/conf 下: spark-defaults.conf 增加如下内容 spark.eventLog.enabled true spark.eventLog.dir hdfs://master:8020/var/log/spark spark.eventLog.compress true spark-env.sh 增加如下内容 export SPARK_HISTORY_OPTS="-Dspark.history.ui.port=18080 -Dspark.history.re

增加Activity Monitor中的作业保存数量

在Master Server的注册表中加入如下两个键值即可: (1500的单位是小时) ?

安装与使用vld查看php的opcode代码

需要分析PHP代码的性能,或者说实现同样功能的代码到底哪个更好呢?或者说想知道底层的实现可以使用VLD查看opcode 下载与安装VLD # wget http://pecl.php.net/get/vld-0.11.2.tgz # tar zxvf vld-0.11.2.tgz # cd ./vld-0.11.2 # /usr/local/php/bin/phpize              或者直接phpize # ./configure --with-php-config=/usr/lo

如何在Code::Blocks下查看程序的汇编代码

学习C语言,Code::Blocks是个不错的IDE.有时候我们需要查看程序的对应的汇编代码,那么Code::Blocks如何才能像vc6.0中那样debug时候查看反汇编代码呢? 首先创建一个工程:Create a new project -> ConsoleApplication -> 填上工程文件名和project路径 -> 调试器和编译器默认. 随便在工程里写点什么代码,比如下面的一个递归代码为例:k7娱乐城 #include "stdio.h" #inclu

Activity里面嵌入Fragment一点小代码

在Activity里面填充界面,可以直接把界面内容写在Activity里面,这不是最好的,有的时候为了模块化会选择下面的方式可以再在Activity里面填充一个Fragment(就是把fragment填充到Activity里面)!! public class ConversionCenterActivity extends BaseFragmentActivity implements Constant{ private ConversionCenterFragment mConversionC