This custom alert checks when the last successful CHECKDB completed against each database and returns the number of hours elapsed since then. If you run CHECKDB weekly, schedule the alert to run once an hour (for early detection) and set the alert threshold to 170 hours (7 days x 24 hours = 168, plus a 2-hour buffer). If you run CHECKDB nightly, use a threshold of 26 (24 hours plus a 2-hour buffer).
What is CheckDB
DBCC CHECKDB is the only built-in way to verify the physical and logical integrity of every page in a database. SQL Server usually doesn’t notice corruption until something reads the damaged page, which can be weeks after it occurs.
Why it matters
- Silent corruption: Storage, drivers, firmware, and memory can damage pages without raising errors. Page checksums catch some of this on read, but only CHECKDB examines all data, including pages nobody has queried recently.
- Corrupt backups: A backup of a corrupt database is itself corrupt. If the problem goes unnoticed past your retention window, no clean backup may remain.
- Logical inconsistencies: Broken index-to-table consistency or allocation structures can cause wrong query results rather than obvious errors.
Why timing matters
Found early, corruption is usually fixed by restoring a good backup and replaying logs with little or no data loss. Found late, the only option may be REPAIR_ALLOW_DATA_LOSS, which deletes data to restore consistency.
Common practice
Run a full CHECKDB at least weekly, aligned with backup retention so a clean check always falls within the backups you can restore from. For very large databases, run it against a restored copy or readable secondary, or split the work with CHECKFILEGROUP or PHYSICAL_ONLY, accepting reduced coverage.
DPA Alert Example
Note: The query used in the SQL Statement field is attached to this article.