Wednesday, October 3, 2012

Task Progress


--This query can be executed with any database context. This is written to show the estimated time in hrs, min and sec and also shows percentage of completion. This is quite helpful to check the backup progress, restore progress, integrity check progress, rebuild index task progress etc.

select
convert (varchar(50),(estimated_completion_time/3600000))+'hrs'+
convert (varchar(50), ((estimated_completion_time%3600000)/60000))+'min'+
convert (varchar(50), (((estimated_completion_time%3600000)%60000)/1000))+'sec'
as Estimated_Completion_Time,
status, command, db_name(database_id), percent_complete
from sys.dm_exec_requests

No comments: