SQL Server2008查询备份进度

方法一:

select command

   ,percent_complete

   ,running_time=convert(varchar,((datediff(s,start_time,getdate()))/3600))+‘ hour, ‘

                +convert(varchar,((datediff(s,start_time,getdate()))%3600/60))+‘ min, ‘

                +convert(varchar,((datediff(s,start_time,getdate()))%60))+‘ sec‘

   ,est_time_to_go=convert(varchar,(estimated_completion_time/1000)/3600)+‘ hour, ‘

                  +convert(varchar,(estimated_completion_time/1000)%3600/60)+‘ min, ‘

                  +convert(varchar,(estimated_completion_time/1000)%60)+‘ sec‘

   ,start_time=convert(char(16),start_time,120)

   ,est_completion_time=convert(char(16),dateadd(second,estimated_completion_time/1000,getdate()),120)

   

   ,s.text

   from sys.dm_exec_requests r

   cross apply sys.dm_exec_sql_text(r.sql_handle) s

   where r.command in (‘BACKUP DATABASE‘,‘RESTORE DATABASE‘,‘BACKUP LOG‘,‘RESTORE LOG‘,‘DbccFilesCompact‘,‘DbccSpaceReclaim‘)


方法二:

USE master
GOSELECT CASE WHEN ((estimated_completion_time/1000)/3600) < 10 THEN ‘0‘ +
CONVERT(VARCHAR(10),(estimated_completion_time/1000)/3600)ELSE CONVERT(VARCHAR(10),(estimated_completion_time/1000)/3600)END + ‘:‘ + 
CASE WHEN ((estimated_completion_time/1000)%3600/60) < 10 THEN ‘0‘ +
CONVERT(VARCHAR(10),(estimated_completion_time/1000)%3600/60) 
ELSE CONVERT(VARCHAR(10),(estimated_completion_time/1000)%3600/60)END  + ‘:‘ + 
CASE WHEN ((estimated_completion_time/1000)%60) < 10 THEN ‘0‘ +
CONVERT(VARCHAR(10),(estimated_completion_time/1000)%60)ELSE CONVERT(VARCHAR(10),(estimated_completion_time/1000)%60)END AS [Time Remaining],
percent_complete,
* FROM sys.dm_exec_requestsWHERE percent_complete > 0


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。