how to repair suspect db
Its good to restore from an earlier backup copy.If you dont have one..below are the steps that can be done to repair suspect database..this has been explained with more examples by Paul Randal here :Creating, detaching, re-attaching, and fixing a SUSPECT database
Overview of steps
- set suspect database offline
- Copy those mdf ldf files to some location
- drop the old suspect database
- create a new database with same name and same file layout
- set this new database offline
- delete the newly created mdf,ldf files and copy old corrupted files
- now try bringing the database online and try repairing with DBCC
below are the scripts
CREATE DATABASE DEMOSUSPECT
ALTER DATABASE DEMOSUSPECT SET OFFLINE
--- you have to copy and drop the old database files prior to this
----NOW DELETE THE mdf and ldf files created for new database
--copy those corrupted files into new location
alter database demosuspect set online
--check status once
SELECT DATABASEPROPERTYEX (N'DemoSuspect', N'STATUS')
--tyr putting the database into emergency mode and use DBCC
ALTER DATABASE [DemoSuspect] SET EMERGENCY;
GO
ALTER DATABASE [DemoSuspect] SET SINGLE_USER;
GO
DBCC CHECKDB (N'DemoSuspect', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;
GO
-- Check the state
SELECT DATABASEPROPERTYEX (N'DemoSuspect', N'STATUS') AS N'Status';
GO
Try This:
EXEC sp_resetstatus [YourDatabase];
ALTER DATABASE [YourDatabase] SET EMERGENCY
DBCC checkdb([YourDatabase])
ALTER DATABASE [YourDatabase] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ([YourDatabase], REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE [YourDatabase] SET MULTI_USER