This is the query to repair suspect database in SQL Server.
If your Database is marked as suspected, here are the steps to fix it.
In this you have replace “dbName” with suspected db name and run this query in master database.
Step 1
--command to recover suspected database
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
This step 1 cannot set Index created for that database so now we have to rebuild the index. This query should be run in that suspected database.
Step 2
-- command to rebuild all indexes
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
cyril smithPosted May 16, 2013, 2:30 AM
There are various errors in SQL Server database and one of them might be issue for you when you are doing some task on the SQL database and because of it your database might goes into suspect mode. For instant and safe recovery and repairing of corrupt SQL files, our SysTools SQL Recovery Software is specially designed for high end algorithms.
Prett SonsPosted Feb 20, 2013, 5:16 AM
There are multiple reasons of suspected SQL Database such as sudden system shutdown, database file corruption, corrupted log file etc. If you database get suspect due to database corruption then there is One another solution to repair suspected database that is third party SQL Database Recovery Software. Stellar Phoenix offers SQL Recovery Software to repair suspected database.