SQL SERVER – Check Database Integrity for All Databases of Server – DBCC CHECKDB

Today we will see quick script which will check integrity of all the databases of SQL Server. We will learn about DBCC CHECKDB in this blog post.

EXEC sp_msforeachdb 'DBCC CHECKDB(''?'')'

The above script will return you lots of messages in resultset. If there are any errors in resultset they will be displayed in red text. If everything is black text there is no error. The typical output of above script will be like image included in the article.

SQL SERVER - Check Database Integrity for All Databases of Server - DBCC CHECKDB dbcccheckdb

The image displayed above is only partial image.

Note from MSDN: DBCC CHECKDB is supported on databases that contain memory-optimized tables, but validation only occurs on disk-Based tables. However, as part of database backup and recovery, a CHECKSUM validation is done for files in memory-optimized filegroups. Since DBCC repair options are not available for memory-optimized tables, you must back up your databases regularly and test the backups. If data integrity issues occur in a memory-optimized table, you must restore from the last known good backup.

Here are few relevant blog posts about DBCC.

Reference: Pinal Dave (http://www.SQLAuthority.com)

Best Practices, SQL Scripts, SQL Server, SQL Server DBCC
Previous Post
SQLAuthority News – SQL Server 2008 Book Online Updated in October 2008
Next Post
SQL SERVER – Delete Backup History – Cleanup Backup History

Related Posts

Leave a Reply