码迷,mamicode.com
首页 > 数据库 > 详细

sql查询备份或还原等操作的大概完成时间

时间:2015-08-29 16:48:34      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

查询出来的还需完成时间还算比较准确

--查询备份或还原等操作的大概完成时间
   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)
  

 

sql查询备份或还原等操作的大概完成时间

标签:

原文地址:http://www.cnblogs.com/davidhou/p/4769275.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!