在创建索引,数据库恢复等耗时操作时,可通过以下方法查看剩余时间
- SELECT
- d.PERCENT_COMPLETE AS [%Complete],
- d.TOTAL_ELAPSED_TIME/60000 AS ElapsedTimeMin,
- d.ESTIMATED_COMPLETION_TIME/60000 AS TimeRemainingMin,
- d.TOTAL_ELAPSED_TIME*0.00000024 AS ElapsedTimeHours,
- d.ESTIMATED_COMPLETION_TIME*0.00000024 AS TimeRemainingHours,
- s.text AS Command
- FROM sys.dm_exec_requests d
- CROSS APPLY sys.dm_exec_sql_text(d.sql_handle)as s
- WHERE d.COMMAND LIKE 'RESTORE DATABASE%'
- ORDER BY 2 desc, 3 DESC
-
可统计为以下命令完成的工作的百分比:
-
ALTER INDEX REORGANIZE
-
AUTO_SHRINK 选项(带 ALTER DATABASE)
-
BACKUP DATABASE
-
CREATE INDEX
-
DBCC CHECKDB
-
DBCC CHECKFILEGROUP
-
DBCC CHECKTABLE
-
DBCC INDEXDEFRAG
-
DBCC SHRINKDATABASE
-
DBCC SHRINKFILE
-
KILL (Transact-SQL)
-
RESTORE DATABASE,
- UPDATE STATISTICS.
-
ALTER INDEX REORGANIZE