My first blog post in a long time!
So I archived some data from our database yesterday and I needed to shrink the database file so I ran the “Shrink Database” task in Management Studio. The database is over 500GB in size and I checked 7 hours later and the database shrink operation is still going. I got a little worried because someone needs to use this database today and I’m not sure if the task would be done by then because the GUI is not showing the progress. I needed to know where the DBCC Shrink operation is currently at or if it’s even doing anything so I can cancel if it doesn’t look like it will finish in time.
The next step I took of course is open up Firefox and used my favorite search engine to look for a way to check the progress. I found this website that explained it and all I needed to do was open Query Analyzer and query sys.dm_exec_requests and look for DbccFilesCompact in the command column.
Here’s an example:
SELECT percent_complete, start_time, status, command, estimated_completion_time, cpu_time, total_elapsed_time
In my case, the percent_complete was already at 94.xxxx and slowly moving so that made me happy. Going from 94 to the end took about 5 hours, by the way. The entire operation took around 12 hours.