- Open Microsoft SQL Server Management Studio
- Connect to the database server instance
- Click New Query
- Type the following commands:
- Click Execute
- Refresh the list of databases
EXEC sp_resetstatus {DatabaseName};
ALTER DATABASE {DatabaseName} SET EMERGENCY
DBCC checkdb({DatabaseName})
ALTER DATABASE {DatabaseName} SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ({DatabaseName}, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE {DatabaseName} SET MULTI_USER
ALTER DATABASE {DatabaseName} SET EMERGENCY
DBCC checkdb({DatabaseName})
ALTER DATABASE {DatabaseName} SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ({DatabaseName}, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE {DatabaseName} SET MULTI_USER
Example:
I want to fix the luizcgjr database that is maked as suspect:
EXEC sp_resetstatus luizcgjr;
ALTER DATABASE luizcgjr SET EMERGENCY
DBCC checkdb(luizcgjr)
ALTER DATABASE luizcgjr SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB (luizcgjr, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE luizcgjr SET MULTI_USER
ALTER DATABASE luizcgjr SET EMERGENCY
DBCC checkdb(luizcgjr)
ALTER DATABASE luizcgjr SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB (luizcgjr, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE luizcgjr SET MULTI_USER
Source: https://support.managed.com/kb/a398/how-to-repair-a-suspect-database-in-mssql.aspx