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 :
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.
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.