Admin-Ahead Community

Windows => General Windows => Topic started by: Chetan Singh on November 30, 2013, 09:24:02 pm

Title: How To Repair A Suspect Database In MS SQL.
Post by: Chetan Singh on November 30, 2013, 09:24:02 pm
Hi,

You have a database in MS SQL that is tagged as suspect and you are unable to connect to the database. It's because the database could have become corrupted.  You can repair database with following steps.

1) Open Microsoft SQL Server Management Studio and connect to your database.
2) Click the New Query button.
3)Paste the following SQL script into your New Query page replacing [YourDatabase] with the name of your database.

=====================>>>
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
=====================>>>

4) Click Execute.

Note:- Always back up the website before making any changes to the database. Your database should no longer be tagged as (suspect) and you should be able to access it.

Thank you,