Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1551
  • Last Modified:

Restoring a suspect SQL Server 2005 database

I have one database that is marked "suspect".  I want to try to repair it rather that restoring it from backup.  Is this possible using the following commands:
USE master;
GO
ALTER DATABASE Altiris
SET db_state_option = EMERGENCY;
GO
USE Altiris
DBCC CHECKDB repair_allow_data_loss;

Please review this for errors.  Also, if this does not work, will I have to set the database to offline to do the restore from backup?
0
Jack Seaman
Asked:
Jack Seaman
2 Solutions
 
udaya kumar laligondlaTechnical LeadCommented:
if you have a back up restore the same that is the best way
if you don't have
some one suggested
EXEC sp_resetstatus 'yourDBname';
ALTER DATABASE yourDBname SET EMERGENCY
DBCC checkdb('yourDBname')
ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('yourDBname', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE yourDBname SET MULTI_USER
to me.
0
 
wolfman007Commented:
Just remember to rebuild the indexes in the database after repairing.

from

http://blogs.microsoft.co.il/blogs/dbaces/archive/2008/12/28/how-to-repair-sql-server-2005-suspect-database.aspx
EXEC sp_resetstatus 'DBName'
GO
ALTER DATABASE DBName SET EMERGENCY
DBCC checkdb('DBname')
ALTER DATABASE DBName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('DBName', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE DBName SET MULTI_USER
 
GO
 
-- Rebuild the index
 
ALTER INDEX ALL ON [ TableName] REBUILD

Open in new window

0
 
CuteDBACommented:
I have my database as suspect and I have the backup, When I try to restore the database (right-click -> tasks -> restore -> database) I find the restore button disabled (gray).

Do I have to follow the steps above then restore ?

Question 2: What data and How much  I am going to lose if this statement is executed:
DBCC CheckDB ('yourDBname', REPAIR_ALLOW_DATA_LOSS)

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now