DBCC command execution History

  • Hi,

    I need an urgent help. I have to provide the result to audit team on when exactly DBCC commands executed in a specific DB. Can anyone please help >

    Thanks in Advance!

  • Which DBCC commands are you tring to audit?

    In most cases you can query the Error log to find out when they are run.

    DECLARE @ErrorLog TABLE

    (

    LogDate DATETIME NOT NULL,

    ProcessInfo VARCHAR(75),

    LogInfo VARCHAR(MAX)

    )

    INSERT INTO @Errorlog

    EXEC xp_readerrorlog

    SELECT *

    FROM @Errorlog

    WHERE LogInfo LIKE '%DBCC%'

  • Thanks a lot for a quick response ! Will this log available in db only for certain period ? because when i execute this in my db it didnt return any result.

  • Doesn't xp_readerrorlog take some parameters. If you don't specify any of the parameters, then it reads only the current log file.

    Error logs can be cycled either manually or by retarting SQL Server. Typically, SQL Server retains backups of the previous six logs and gives the most recent log backup the extension .1, the second most recent the extension .2, and so on. The current error log has no extension.

    So it could be that it is not in the current log file.

    Just try opening the SQL Server Error Logs in SQL Server Management Studio.

    1. In Object Explorer, expand a server, expand Management, and then expand SQL Server Logs.

    2. Right-click a log and click View SQL Server Log.

  • to be more specific on my question i need to know when did DBCC Checkident applied for a table recently ....

  • vstitte (2/1/2010)


    Doesn't xp_readerrorlog take some parameters.

    Correct. I just use the above script as a job to notify me of any certain alerts

    You could try

    EXEC xp_readerrorlog 6,1,'dbcc'

    Change the 6 to be the number of logs you keep...

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply