How to Deal with SQL Server 2008 R2 Error 926?

Summary: This blog discusses error 926 that occurs while working on SQL Server 2008 R2. It also provides solutions on how to deal with SQL Server 2008 R2 Error 926. You can also try Stellar Repair for MS SQL software to restore your database without downtime and data loss. Try the demo version of the software to preview all the recoverable database objects.

About SQL Server Error 926

Suppose you write an SQL query and are ready to execute it in SQL Server 2008 R2; but as you input the code, you get the following error message:

Database ?msdb? cannot be opened. It has been marked SUSPECT by recovery. See the SQL Server errorlog for more information. (Microsoft SQL Server, Error: 926).

Figure 1 ? Microsoft SQL Server, Error: 926 Message

The above error message indicates that ?database is marked as suspect due to failed recovery process?, which prevents the database from opening. So, you will need to repair or recover MS SQL database from suspect mode to make it accessible again.  

Following are some operations that result in SQL error 926:

How to Fix SQL Server 2008 R2 Error 926?

Check the SQL Server error log to identify what caused the error. If the recovery failed due to an I/O error (a torn page) or any other hardware issue, try resolving the hardware issue first to fix the error. If this doesn?t work, there must be some form of database corruption. In that case, try restoring the database from the last known database backup.

If you don?t have recent backup or the backup is corrupt, set the database in EMERGENCY mode and try the DBCC CHECKDB repair operations. Doing so will help you restore access to the database marked as suspect. But, before attempting this solution, try the following tricks to fix Microsoft SQL Server 2008 R2 Error 926 MSDB:

  1. Refresh the SQL connection.
  2. Disconnect and reconnect the SQL connection.
  3. Restart the service for MSSQLSERVER.
  4. Restart the SQL Server Management Studio (SSMS).
  5. Restart your desktop.

If none of the above tricks help resolve the error, perform these steps:

Step 1: Use EMERGENCY Mode to Repair a Suspect Database

Open a new query window in SSMS, and then run the following commands:

Note: You can also use the ?sp_resetstatus? stored procedure to turn off the suspect flag on a database. For detailed information, refer to this link.

ALTER DATABASE DB_Name SET EMERGENCY;

This command puts the database in EMERGENCY mode. In this mode, users only get read-only permission to access the database.

Note: Members of the sysadmin fixed server can only access this right.

DBCC CHECKDB (?DB_Name?);

The above command helps check the integrity of all database objects.

ALTER DATABASE DB_Name SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

The command sets the database in ?single user mode?.

DBCC CHECKDB (?DB_Name?, REPAIR_ALLOW_DATA_LOSS);

This DBCC CHECKDB command will help repair the errors in SQL Server 2008 R2.

ALTER DATABASE DB_Name SET MULTI_USER;

With this command, the SQL Server database will be set in multi-user mode, allowing multiple users to access the database.

After executing all of the above commands, check if you can access the database. If you can, put the db back in normal mode.

Read this: Recover SQL Database from Emergency Mode to Normal Mode

If this step fails, proceed with the next step.

Step 2 ? Move and Detach MSDB File

You can try to recover suspect MSDB database by moving and detaching the MSDB data and log files. For this, you can use SQL Server Management Studio (SSMS) or T-SQL:

Using SSMS

  1. Open Object Explorer in SSMS, right-click the connected SQL Server instance and then click Stop.

Figure 2 ? Stop SQL Server Instance

2. Open Control panel, browse and select administrative tools, and then click Services.

Figure 3 ? SQL Server Services

3. In ?Services? dialog box, locate and right-click on SQL Server (MSSQLSERVER), and then click Stop.

Figure 4 ? Stop SQL Server Service

4. Open C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA.

5. Move the MSDB data file (.mdf) & log file (.ldf) to any other folder or location.

6. Copy the .mdf and .ldf files from the new location to their original location by browsing the following path:

C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA

7. Restart SQL Server Service.

8. Refresh the database, and detach the MSDB file

Using T-SQL

You can also recover the MSDB database in suspect mode by executing the below T-SQL query:

EXEC sp_resetstatus ‘db_name’ ALTER DATABASE db_name SET EMERGENCY DBCC CHECKDB (‘db_name’) ALTER DATABASE db_name SET SINGLE_USER WITH ROLLBACK IMMEDIATE DBCC CHECKDB (‘db_name’, REPAIR_ALLOW_DATA_LOSS) ALTER DATABASE db_name SET MULTI_USER

Note: Replace db_name with the name of your database marked as suspect.       

The above code will turn off the suspect flag on the database and put it in emergency mode. Next, it will bring the database to single-user mode, repair it, and will put the database to multi-user mode.

Limitations of Resolving SQL Server Error 926 Manually

There are a few downsides to using the aforementioned manual workarounds to resolve SQL error 926:

Alternative Solution to Fix SQL Server 2008 R2 Error 926

SQL database recovery software can resolve any error, including error 926 in SQL Server causing databases to become inaccessible.

Also, the SQL database repair software can help you overcome the limitations of the above-discussed solutions, here?s how:

You can download the demo version of the SQL database repair software to ascertain its effectiveness.

 Key Features of Stellar Repair for MS SQL

Conclusion

You can use manual fixes and software to deal with SQL Server 2008 R2 Error 926. While the manual fixes may help you fix the error, they may take considerable time and effort in resolving the error. This increases server downtime, leading to productivity loss and chances of data loss. However, using SQL repair software may help you restore the database in minimal time without the fear of losing any data.

Related Post