how to automate dbcc checkdb

  • cdm33.com (7/30/2014)


    SQLRNNR,

    This code has hundreds of lines to it. I've got no clue what it does. I'm not going to put something like this on a production server not knowing what it does.

    THanks anyway.

    I agree with you that putting an unknown script on a production server is never a good idea.

    However there are some very well known scripts around that have gained great popularity throughout the years, such as Adam Machanic's sp_WhoIsActive or Ola Hallengren's maintenance solution.

    If you prefer, Ola's solution contains a script for consistency check and his script is much more "famous" and widely used than mine.

    Ciao

    Gianluca

    -- Gianluca Sartori

  • Oooops! I hit the wrong button...

    -- Gianluca Sartori

  • cdm33.com (7/31/2014)


    Janson, Grant and Ed,

    After poking around and reading what you had to say about what I wanted to do, I think I'm off to a good start. It's just a pain trying to do stuff without a lab sometimes.

    Great forum by the way.

    Thanks a lot,

    Chris

    Strong suggestion, get a test lab of some kind. A virtual machine running on VMware, HyperV, VirtualBox, anything, is good enough, so you can validate stuff before it goes to production.

    And welcome to the forum.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey (8/1/2014)


    cdm33.com (7/31/2014)


    Janson, Grant and Ed,

    After poking around and reading what you had to say about what I wanted to do, I think I'm off to a good start. It's just a pain trying to do stuff without a lab sometimes.

    Great forum by the way.

    Thanks a lot,

    Chris

    Strong suggestion, get a test lab of some kind. A virtual machine running on VMware, HyperV, VirtualBox, anything, is good enough, so you can validate stuff before it goes to production.

    And welcome to the forum.

    Let me second Grant's suggestion. Even a decent desktop PC running SQL Server that sits under your desk is better than nothing. You don't even have to load it up with everything from production, just a good representation of your databases. The ideal scenario would be to have a copy of production sitting in test with the same hardware, SAN drives and everything else, but I don't know of anyone (including myself) who actually gets budget for that.

  • 😀

  • Hi cdm33.com

    I thought I would mention what I do to see if that helps you.

    I have DBCC checks for databases scheduled in a SQL job. The output of the DBCC is saved to a .txt file on the server - so the results of the DBCC command are available for us to review.

    You can then use DBMail to send an email with the .txt file as an attachment. So you could have an extra step in your job that uses TSQL for this step. There are some examples available online that will show you how to do this, but this gives you a start

    http://msdn.microsoft.com/en-gb/library/ms190307(v=sql.105).aspx

    I hope that helps.

    Em.

  • Hello Grasshopper,

    What i'm doing is saving the output from the dbcc job to text file on the server. Then using a poswershell script to parse out what i want from the file and sending that out via another statement from the powershell script:

    get-content C:\logs\dbcc-log.txt | select-string 'CHECKDB found' | out-string | out-file dbcc.txt

    the above will save the errors to file (if any) - if not, it will say 0 errors. then, i do a send-mailmessage with the attached file. it's pretty efficient and i don't mess around with the dbmail part of it.

    cdm33

Viewing 7 posts - 16 through 21 (of 21 total)

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