【问题标题】:Get the SQL Server Agent job that has run a particular execution of a deployed SSIS package获取已运行已部署 SSIS 包的特定执行的 SQL Server 代理作业
【发布时间】:2018-12-13 04:30:14
【问题描述】:

我在 SQL Server 中部署了一个 SSIS 包,并且有 3 个不同的 SQL Server 代理作业以不同的步骤和计划运行此包。

我的问题是:如果包在集成服务目录中显示为失败 -> 在其中一个执行中报告,有没有办法我可以确定哪个作业是运行导致包失败的执行的作业(不是通过从作业历史和包失败执行时间交叉检查失败时间)?

【问题讨论】:

    标签: sql-server ssis sql-job


    【解决方案1】:

    这不是很直接。基于this stack exchange answer,你可以试试:

    SELECT 
     history.*
    ,ex.* 
    ,ex.status
    , CASE ex.status
        WHEN 1 THEN 'created'
        WHEN 2 THEN 'running'
        WHEN 3 then 'canceled'
        WHEN 4 then 'failed'
        WHEN 5 then 'pending'
        WHEN 6 then 'ended unexpectedly'
        WHEN 7 then 'succeeded'
        WHEN 8 then 'stopping'
        WHEN 9 then 'completed'
    END as job_status
    FROM (
        SELECT 
            h.step_name,  
            -- h.message, 
            h.run_status, 
            h.run_date, 
            h.run_time, 
            SUBSTRING(h.message, NULLIF(CHARINDEX('Execution ID: ', h.message),0)+14 ,PATINDEX('%[^0-9]%',SUBSTRING(h.message, NULLIF(CHARINDEX('Execution ID: ', h.message),0)+14 ,20))-1) ExecutionId
        FROM MSDB.DBO.SYSJOBHISTORY h) history
    LEFT JOIN 
    SSISDB.CATALOG.EXECUTIONS ex on ex.execution_id = history.ExecutionId
    WHERE project_name = '<ssisdb_project_name_here>'
    

    它有很多列,您可以通过在选择中替换 * 来忽略它们。重要的部分是加入MSDB.DBO.SYSJOBHISTORYMSDB.DBO.SYSJOBHISTORY

    另外,这适用于项目部署模式,不适用于 SSIS 的包部署模式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-01
      • 1970-01-01
      • 2021-07-09
      • 2015-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多