2

I'm administrating a database that became corrupt and I tried to do a REPAIR_REBUILD.

The server on this installation is a bit weak but the database isn't that big (roughly 2GB).

It's been running for 48 hours and still not completed. Is it possible ? And is there any way to check the current state other than just seeing "Executing query" ?

  • How many indexes was corrupted? 48 hours seem exagerated as in 48 hours it's possible to rebuild all non-clustered indexes of 2Gb database – sepupic Jul 26 '17 at 9:52
2

You could always run the following script to check the running tasks:

SELECT 
    start_time,
    DATEADD(ms,estimated_completion_time,GETDATE()) AS 'EstimatedEndTime',
    percent_complete,
    --sqltext.TEXT, 
    req.session_id, 
    req.status, 
    req.command, 
    req.cpu_time, 
    req.total_elapsed_time
FROM sys.dm_exec_requests req 
CROSS APPLY sys.dm_exec_sql_text(req.sql_handle) 
where req.command like '%DBCC%'

Comment out the sqltext.TEXT column if you wish to view the whole statement.

1

Try this query (change session_id for your own that executed the command):

select session_id, command, percent_complete

from sys.dm_exec_requests

where session_id=55
  • Why session_id=55; – Md Haidar Ali Khan Jul 26 '17 at 9:44
  • it was just an example. Read the full text. I said to replace session_id for the one he executed the command. – Renato Afonso Jul 26 '17 at 10:23
  • @hot2use - Wouldn't that give you the % complete of this script, not of the connection running the CHECKDB? – RDFozz Jul 26 '17 at 15:37
1

Yes , you can check the current status of the DBCC Checkdb.

  • Run sp_who2 and identify the spid which is running the DBCC CHECKDB
  • Once you have the SPID, use it to identify the % with below query:

Select session_id, command, percent_complete from sys.dm_exec_requests where session_id= Your_SPID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.