Generally, any hidden corruption in the SQL database drags down your performance significantly and makes the database more sluggish and unresponsive. In the worst scenarios, you may not be able to perform any operation on the database. This situation usually indicates that the database has an incorrect or inconsistent status or has gone in ‘Suspect/Offline’ mode.
The above problem may occur when MS SQL Server incorrectly interprets the free data page space while performing a row insertion. Other reasons include abrupt server reboot, hard disk running out of space, missing device files, etc.
To resolve the issue, you may go to the ‘Mssql\Install’ directory and execute the ‘Instsupl.sql’ script in the first place. This will create the stored procedure ‘sp_resetstatus’ that can be used to reset the status of your suspect database. Next, you need to check for corruption in the database that will help you determine the root cause or the underlying issue.
Initially, you should set the database to emergency mode and then run DBCC CHECKDB against the database. The DBCC CHECKDB tool will acknowledge you with the minimum repair level that would be required for your database. If the minimum repair level is ‘REPAIR_ALLOW_DATA_LOSS’, you are very likely to experience data loss.
In order to resolve the issue, follow the below procedure:
- Run the following command to set your database to emergency mode:
ALTER DATABASE DatabaseName SET EMERGENCY
- Try to fix data corruption using the following set of commands:
ALTER DATABASE DatabaseName SET SINGLE_USER; GO DBCC CHECKDB (DatabaseName, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS; GO
Additionally, you may require performing one or more of the following actions:
- Modify or update statistics.
- Copy all recoverable data in the damaged table to a new table.
- Drop and recreate one or more indexes.
- Use ‘sp_recompile’ for recompiling your stored procedures and triggers.
If the above procedures are unable to resolve the problem and your SQL database is still marked as ‘Suspect’, try restoring the database form a clean updated backup. You may also set your database to emergency mode and use the bulk copy program (BCP) for copying or moving your valuable data out. If you encounter more problems, use Stellar Phoenix SQL Recovery tool to perform suspect SQL database repair.
Stellar Repair for MS SQL is an advanced SQL repair tool that performs a comprehensive scan of the corrupt database and retrieves every bit of lost, deleted or inaccessible data. The proficient utility effectively restores all MDF and NDF file components, including tables, views, indexes, queries, constraints, stored procedures, user-defined functions, etc. You can also save the recovered queries, views, stored procedures etc. in a separate text file. Furthermore, the software supports the latest SQL Server versions, including MS SQL Server 2016, 2014, 2012, 2008, 2008 R2 and lower versions.