WinTill :: Knowledge Base

Check Databases For Corruption

If you suspect corruption in one or more of your databases, or just to check for corruption in any of your databases, then execute the following script. This script will create a stored procedure isp_CheckServerForCorruption in the master database. Simply execute this script and view the printed output for results. If the script already exists, simply execute the script.

USE Master
Create Procedure isp_CheckServerForCorruption
Declare @DBName sysname,@Message varchar(255)
Declare curDatabases cursor
for select [name] from master..sysdatabases
Open curDatabases
fetch next from curDatabases into @DBName
While @@FETCH_STATUS = 0
Begin Set @Message = '*****BEGIN Processing ' + @DBNAME + '********'
print @Message
declare @SQL varchar(255)
Set @SQL = 'DBCC CHECKDB(' + @DBName + ') with PHYSICAL_ONLY'
Set @Message = '*****END Processing ' + @DBNAME + '********'
print @Message
fetch next from curDatabases into @DBName
Close curDatabases
Deallocate curDatabases

Related Articles


No attachments were found.

Visitor Comments

Article Details

Last Updated
7th of March, 2011

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions

No users have voted.

How would you rate this answer?

Thank you for rating this answer.