Easily Check Database Integrity (DBCC CHECKDB) For All Databases On A Server — Parv The IT Geek

Today I was doing my daily checks on one of my biggest SQL instances which has over 1,000 databases and noticed that SQL Agent was stopped. I couldn’t see any errors and was able to simply start it without any problems but I was concerned that the daily integrity check jobs had not run and I am way too cautious to get caught by not doing it manually.

Initially I wasn’t too sure how to do it very quickly without creating a script using DBCC CHECKDB, querying sys.databases with some dynamic T-SQL but decided to give the below script a try and luckily it worked.

EXEC sp_MSforeachDB ‘DBCC CHECKDB (?)’


Originally published at https://parvtheitgeek.com on January 16, 2014.

Published by Parvinder Nijjar

I blog at ParvTheITGeek.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: