2

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

4
  • Can you post some examples of what you are seeing? Commented Nov 7, 2013 at 10:49
  • 2013-11-08T05:30:22.700 CHECKDB for database 'CHECKPOST' finished without errors on 2013-11-03 00:02:56.417 (local time). This is an informational message only; no user action is required. 2013-11-08T05:30:20.530 CHECKDB for database 'CHECKPOST' finished without errors on 2013-11-03 00:02:56.417 (local time). This is an informational message only; no user action is required. 2013-11-08T04:45:22.610 CHECKDB for database 'CHECKPOST' finished without errors on 2013-11-03 00:02:56.417 (local time). This is an informational message only; no user action is required. Commented Nov 8, 2013 at 5:50
  • The Above message is repeatably occurs Commented Nov 8, 2013 at 5:50
  • 2
    Is the database set to AUTO_CLOSE? Commented Nov 8, 2013 at 11:21

1 Answer 1

5

I think @MartinSmith nailed it in his comment. When you have AUTO_CLOSE set to ON, 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 time DBCC 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:

create database AutoCloseDb;
go

alter database AutoCloseDb
set auto_close on;
go

dbcc checkdb('AutoCloseDb');
go

-- rotate the below "use" statements a few times in order
-- to cause the database to close and reopen
--
use AutoCloseDb;
go

use master;
go

After we do a few rotations of use AutoCloseDb; followed by use master;, we would see something similar to the below in the SQL Server error log (I use the below PowerShell code to retrieve this):

Add-Type -Path "C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Smo.dll"

$SqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server("<your SQL Server name>")

$SqlServer.ReadErrorLog() |
    Where-Object {$_.Text -like "*AutoCloseDb*"} |
    Select-Object LogDate, Text |
    Format-List

And in my test environment, the output is the following:

LogDate : 11/15/2013 5:47:17 AM Text : Starting up database 'AutoCloseDb'.

LogDate : 11/15/2013 5:47:18 AM Text : CHECKDB for database 'AutoCloseDb' finished without errors on 2013-11-15 05:39:19.137 (local time). This is an informational message only; no user action is required.

LogDate : 11/15/2013 5:47:18 AM Text : Starting up database 'AutoCloseDb'.

LogDate : 11/15/2013 5:47:18 AM Text : CHECKDB for database 'AutoCloseDb' finished without errors on 2013-11-15 05:39:19.137 (local time). This is an informational message only; no user action is required.

LogDate : 11/15/2013 5:47:19 AM Text : Starting up database 'AutoCloseDb'.

LogDate : 11/15/2013 5:47:19 AM Text : CHECKDB for database 'AutoCloseDb' finished without errors on 2013-11-15 05:39:19.137 (local time). This is an informational message only; no user action is required.

LogDate : 11/15/2013 5:48:25 AM Text : Starting up database 'AutoCloseDb'.

LogDate : 11/15/2013 5:48:26 AM Text : CHECKDB for database 'AutoCloseDb' finished without errors on 2013-11-15 05:39:19.137 (local time). This is an informational message only; no user action is required.

LogDate : 11/15/2013 5:49:30 AM Text : Starting up database 'AutoCloseDb'.

LogDate : 11/15/2013 5:49:30 AM Text : CHECKDB for database 'AutoCloseDb' finished without errors on 2013-11-15 05:39:19.137 (local time). This is an informational message only; no user action is required.

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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