DatabaseIntegrity CheckDB Job

  • Hi, i am using the ola's script for checkDB integrity,its all working well and i set the job to send me the email when the job succeeds.Is it possible to get the results in the mail?
    eg.  CHECKDB found 0 allocation errors and 0 consistency errors in database 'TSQL2012'.
    DBCC execution completed. If DBCC printed error messages, contact your system administrator.

    Thank you

  • I tried something like this myself.  I think you need to create a table for the results and then modify the stored procedure to run DBCC CHECKDB with the (undocumented) TABLERESULTS parameter.

    John

  • Thanks John,did you do so

  • Can i not create an alert?

  • tmmutsetse - Monday, February 5, 2018 7:22 AM

    Can i not create an alert?

    What kind of alert?  You can use the TABLERESULTS option and query the ensuing table, you can read the errorlog, or you can attempt to capture the message output of the DBCC command.  Only you know what your exact requirements are, and only you know what infrastructure you have in place to satisfy those requirements.  I would recommend that you read the Understanding DBCC Error Messages and Error Reporting sections of this page.

    John

  • DECLARE
        @Email SYSNAME = 'me@domain.co.xx',
        @Query NVARCHAR(MAX) = N'DBCC CHECKDB(' + QUOTENAME(DB_NAME()) + ') WITH ALL_ERRORMSGS, NO_INFOMSGS';

    EXEC msdb..sp_send_dbmail
        @profile_name = 'ProfileName',
        @recipients = @Email,
        @subject = 'Subject',
        @query = @Query

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]

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

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