活动监视器查询

时间:2014-02-18 12:24:49

标签: sql sql-server

以下查询有何作用? 我在Activity Monitor上得到了它,与数据库恢复有关。

SELECT  command,
    s.text,
    start_time,
    percent_complete, 
    CAST(((DATEDIFF(s,start_time,GetDate()))/3600) as varchar) + ' hour(s), '
        + CAST((DATEDIFF(s,start_time,GetDate())%3600)/60 as varchar) + 'min, '
        + CAST((DATEDIFF(s,start_time,GetDate())%60) as varchar) + ' sec' as running_time,
    CAST((estimated_completion_time/3600000) as varchar) + ' hour(s), '
        + CAST((estimated_completion_time %3600000)/60000 as varchar) + 'min, '
        + CAST((estimated_completion_time %60000)/1000 as varchar) + ' sec' as est_time_to_go,
    DATEADD(second,estimated_completion_time/1000, getdate()) as est_completion_time 
FROM    sys.dm_exec_requests r
CROSS APPLY
    sys.dm_exec_sql_text(r.sql_handle) s

WHERE   r.command IN ('RESTORE DATABASE', 'BACKUP DATABASE', 'RESTORE LOG', 'BACKUP LOG')

1 个答案:

答案 0 :(得分:0)

此命令将为您提供当前正在执行的备份/恢复进程的状态。如果您不是运行脚本的人,那么您需要确定如何以及何时运行该脚本。也许它正在制造僵局。

这些网站可能会对您有所帮助: