维护计划上次运行 [英] Maintenance Plan last ran

查看:82
本文介绍了维护计划上次运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人知道(或目前正在使用)一个简单的查询,可以提取维护计划的时间戳和状态,就像上次运行一样? 我想自动生成一份收集此信息并在其上报告的报告,但首先需要一个简单的方法
来查询信息。 非常感谢任何帮助。

Would anyone know of (or currently use) a simple query that can pull the time stamp and status of a maintenance plan as it was last ran?  I would like to automate a report that collects this information and reports on it but first need an easy way to query for the information.  Any assistance would be greatly appreciated.

推荐答案

 参考
以下  for
report

 refer following  for report

SELECT
    mp.name AS [MTX Plan Name],
    msp.subplan_name AS [Sub Plan Name],    
    mpl.start_time AS [JobStart],
    mpl.end_time AS [JobEnd],
    mpl.succeeded AS [JobSucceeded]
FROM
    msdb.dbo.sysmaintplan_plans mp
    INNER JOIN msdb.dbo.sysmaintplan_subplans msp ON mp.id = msp.plan_id
    INNER JOIN msdb.dbo.sysmaintplan_log mpl ON msp.subplan_id = mpl.subplan_id
     --   AND mpl.task_detail_id = -- Get the most recent run for this database
            (SELECT TOP 1 ld.task_detail_id 
            FROM msdb.dbo.sysmaintplan_logdetail ld
            WHERE ld.command LIKE ('%['+db_name()+']%')
            ORDER BY ld.start_time DESC)


这篇关于维护计划上次运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆