Sep 26, 2018

SQL Query to see how long DBCC CHECKDB will take

Last night while converting a VMWare VM to a XenServer VM I had a little bit of an issue with one of the database VMs, and several of the databases came up as "Suspect."

We decided to follow this procedure here (How to fix a Suspect Database) and it went fairly quick except on the biggest database that was almost 100GB in size.

Well, we wanted to know how long it would take for the DBCC CHECKDB to finish! I'm sure you are here because you are in the same position. Well, here is a query that will give you an estimated completion time so you have a rough estimate on how long it will take:

 SELECT session_id ,  
 request_id ,  
 percent_complete ,  
 estimated_completion_time ,  
 DATEADD(ms,estimated_completion_time,GETDATE()) AS EstimatedEndTime,   
 start_time ,  
 status ,  
 command   
 FROM sys.dm_exec_requests  
 WHERE database_id = <YOUR DATABASE ID NUMBER>  


Fairly simple right? Your output will look like this:


If you are wondering how to find your database_id you can find it by running this query:

 Use <DATABASE NAME>  
 Select DB_ID() AS [Database ID]  
 GO  

Again, fairly simple right? I hope this helped!



Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | stopping spam