Today we will see quick script which will check integrity of all the database of SQL Server.
EXEC sp_msforeachdb 'DBCCÂ CHECKDB(''?'')'
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. Typical output of above script will be like image included in the article.

Image displayed above is only partial image.
Reference : Pinal Dave (http://www.SQLAuthority.com)




Yes this is a neat trick, however, sp_msforeachdb is going to be deprecated in a future release of SQL and Microsoft doesn’t recommend using it in scripts.