Database Integrity Check

A database integrity check runs DBCC CHECKDB to find corruption before it finds you: damaged pages are far easier to deal with when you spot them early and still have a clean backup to restore from. I run it weekly with Ola Hallengren’s DatabaseIntegrityCheck, and Microsoft’s DBCC CHECKDB documentation covers what the checks do.

Installing the database integrity check procedure

This post used to hold a 2016 copy of Ola Hallengren’s DatabaseIntegrityCheck procedure. Ola keeps his Maintenance Solution up to date (version 2026-09-12 at the time of writing), so always install the current version from his site rather than an old copy:

  • SQL Server Integrity Check – documentation and examples
  • Downloads – MaintenanceSolution.sql installs DatabaseIntegrityCheck together with CommandExecute and CommandLog, which it needs
  • GitHub – the same scripts, with release notes

Running the database integrity check

Once installed, this is how I run it from SQL Agent job steps – system databases and user databases as separate jobs:

EXECUTE dbo.DatabaseIntegrityCheck
    @Databases = 'SYSTEM_DATABASES',
    @CheckCommands = 'CHECKDB',
    @LogToTable = 'Y';

EXECUTE dbo.DatabaseIntegrityCheck
    @Databases = 'USER_DATABASES',
    @CheckCommands = 'CHECKDB',
    @LogToTable = 'Y';

The job that runs it is in the Job_Integrity_Check post. To see when each database last passed CHECKDB, run Health Check 09: integrity checks.

From my SQL Server DBA handbook.