How long since you ran DBCC CHECKDB?

If you’re not regularly looking for corrupt databases with DBCC CHECKDB, you’re putting your organization’s data at risk. I run DBCC CHECKDB once per day, or as is reasonably possible. Typically, DBCC CHECKDB is setup as part of nightly maintenance.

If you’re not regularly looking for corrupt databases, you’re putting your organization’s data at risk!

Hopefully, you have SQL Server Agent jobs running DBCC CHECKDB, and when those jobs fail or report corruption, you’re all over fixing the problem. But, what if you create a database and forget to setup a scheduled DBCC CHECKDB job? The script below reports when the last checkdb operation completed for each database, with a column showing “at-risk” databases with an “X”; that is databases where the last DBCC CHECKDB occurred more than @MaxDaysWithoutCheckDB days ago. Modify that parameter to suit your needs.

I’ve updated the above script to ensure compatibility with case-sensitive collations (thanks Konstantin Taranov for catching that!), and in response to the comment below from Robert, have added an Isreadonly column to the output to show when a database is read-only.

Ads by Google, Paying the Rent: