Alessandro Damiani Blog

Deliri tecnologici e varie amenità da un aspirante apprendista stregone ;)

SqlServer DB in suspect mode…

Did you find your  BiztalkMsgBoxDB  (or any other sql server 2005 DB ) in suspect mode ?

 

What to do to repair it?  Ok, please don’t cry and execute this script in your sqlserver management studio:

 

Declare @DB sysname;
set @DB = 'BizTalkMsgBoxDb';
-- Put the database in emergency mode
EXEC('ALTER DATABASE [' + @DB + '] SET EMERGENCY');
-- Set single user mode
exec sp_dboption @DB, 'single user', 'TRUE';
-- Repair database
DBCC checkdb (@DB, repair_allow_data_loss);
--Or REPAIR_FAST or REPAIR_REBUILD to avoid data loss
-- Turn off single user mode
exec sp_dboption @DB, 'single user', 'FALSE';
--
EXEC('ALTER DATABASE [' + @DB + '] SET  ONLINE');

That’s it .. :D

Posted: 02-23-2009 8:01 by Vanpelt | with no comments