I have an issue with dbcc checkdb command . In the errorlog file I find the dbcc checkdb command multiple time within the interval of 30-45 minutes. I have scheduled a job which grep keyword error from the errorlog file but due to dbcc checkdb all the dbcc checkdb command my mail is simply full with it.
Can anyone please help me on this that why we use dbcc checkdb command and what is the use of it. Is this behavior is ok or we need to take some action over it.
Please help me out.
Thanks,
Nitesh Kumar
Best Answer
I think @MartinSmith nailed it in his comment. When you have
AUTO_CLOSE
set toON
, then the database will shutdown when the last user exits. Likewise, when somebody attempts to use the database it will reopen. When the database reopens, a message about the last timeDBCC CHECKDB
ran will be logged.Take the below example (sample code, not meant to be run anywhere near a production environment) to show proof of this:
After we do a few rotations of
use AutoCloseDb;
followed byuse master;
, we would see something similar to the below in the SQL Server error log (I use the below PowerShell code to retrieve this):And in my test environment, the output is the following:
If it is indeed
AUTO_CLOSE
that is causing this logging behavior in your case, you should see the similar message of "Starting up database ..." in your error log.If this is not what you're seeing, then please modify your question to include other error log events surrounding the
DBCC CHECKDB
logging.