Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / SQL

Time remaining of Database Shrink

5.00/5 (3 votes)
19 Apr 2011CPOL 22.5K  
Time remaining of Database Shrink
I found a stored procedure already in my database (via legacy), and modified it to display remaining seconds and lapsed seconds.

SQL
SELECT percent_complete, start_time, status, command, estimated_completion_time/1000/60 As 'Minutes to Completion', total_elapsed_time/1000/60 As 'Minutes Elapsed', wait_type, last_wait_type
FROM sys.dm_exec_requests
order by 'Minutes to Completion' desc


This is useful when you must perform a shrink or another time consuming task. It does not give much help besides "start_time" and "status" for ad hoc queries though.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)