Tuesday, September 22, 2009

Automate DBCC CHECKDB

Automate DBCC CHECKDB


DOWNLOAD THE CODE:
DBCC CHECKDB :The safest repair statement to identifies and repairs the widest possible errors in the
database.This has to be scheduled to run on all the databases to check errors.If its a shared server which
contains more than 10 databases ( mostly intranet based database applications) then executing
DBCC CHECKDB manually is a time consuming task.

Below script will execute the DBCC CHECKDB command in all the databases except system databases
and generates a report file in html format.

Attached file contains 2 script files  as below :

DBCC_ALL.BAT

This is a batch file contains the code to execute the DBCC CHECKDB command on  all the database
 except the system databases ,generates and save the output in a directory "files" under the default directory
 of this batch file.currently this batch file is using the SQL Server name "" , you have to replace this name
with your SQL Server name in the first line as below.
set vServer=

REPORTGENERATOR.VBS

This is a VB script file which will be executed from the DBCC_ALL.bat(Above Code)  file to  generate the
HTML file contains the report of all the databases and their status.
If you found any database name in blue font in the html file then there is no errors in the database ,
if any names are in red font then there are some errors which you can see through click on the file name.

Watch the execution of this script in the below video.

2 comments:

  1. is there any sequence that i should follow to execute and is there any way to get the report in SSRS

    ReplyDelete
  2. how to setup a notification based on the errors in DBCC CHECKDB

    ReplyDelete

Featured Post

SQL Server AWS Migration BCP

stored procedure to generate BCP scritps to migrate the SQL Server database. Developed this stored procedure on my labs to simulate t...

Contributors