Friday, 4 February 2011

Check for and resolve minor SQL Database corruption

Check for corruption:
DBCC CHECKDB(‘database_name’)
GO

To fix any errors the database must be in single user mode.

ALTER DATABASE database_name SET SINGLE_USER
GO

DBCC CHECKDB('database_name', REPAIR_REBUILD)
GO

ALTER DATABASE database_name SET MULTI_USER
GO

Further details on DBCC CHECKDB can be found here.

No comments: