How to Fix Error 832 in MS SQL Server?

Summary: The error 832 in MS SQL can occur if there is a problem with database pages. In this post, we will learn the ways to detect this error and discuss different solutions to fix this error. We will also mention an SQL database repair tool that can easily and quickly repair the corrupt database.

The error 832 is an error related to problems in the SQL Server pages. This error occurs when an external tool (outside the database engine) affects the database pages. The complete error message looks like this:

Msg 832, Level 24, State 1, Line 1

A page that should have been constant has changed (expected checksum: 0xE7F987A3, actual checksum: 0xA2B9E4F1, database id: 5, file id: 1, page id: 123456789, expected file size: 1048576, created timestamp: 2023-07-15 10:34:28.283).

The Level 24 indicates that it is a critical error. This error is related to a problem in the hardware or operative system that has affected one or more pages in the database. In addition, it can happen if a running thread in an MS SQL Server process incorrectly writes on a page in the database.

How can we detect this error?

There are different ways to detect this error. You can look for this error in the Event Viewer. To open the Event Viewer, type event Viewer in the Search textbox in your taskbar in your Windows OS.

In the Event Viewer, go to Windows Logs > Application. Optionally, you can customize the Filter options to find the error.

Alternatively, you can look for this error in the SQL Server Error Log. In the SQL Server Management Studio (SSMS), go to SQL Server Agent > Error Logs. When you open the log, you will see the SQL Server error messages, including the error 832.

Ways to Fix the Error 832 in MS SQL Server

Here are some ways you can try to fix the error 832 and restore the database.

Restore the Last MS SQL Database Backup

The easiest way to fix this problem is to use your last backup or the backup with the date closest to your needs. The following T-SQL command shows how to restore your database.

RESTORE DATABASE stellardb
FROM DISK = ‘e:\backups\stellardb.bak’

The above command restores the backup, named stellardb.bak, stored in the e:\backups folder.

Alternatively, you can use the SQL Server Management Studio (SSMS) to restore the database. Follow these steps:

Use the DBCC CHECKDB Command

If you do not have a backup, you can try to repair the database using the DBCC CHECKDB command. The following commands can be used to repair the database:

ALTER DATABASE stellardb SET EMERGENCY;

ALTER DATABASE stellardb SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

DBCC CHECKDB (stellardb, REPAIR_REBUILD) WITH NO_INFOMSGS, ALL_ERRORMSGS;

ALTER DATABASE stellardb SET MULTI_USER;

The first command sets the database, named stellardb, in emergency mode:

ALTER DATABASE stellardb SET EMERGENCY;

The second command sets the database in single-user mode with an immediate rollback.

DBCC CHECKDB (stellardb, REPAIR_REBUILD) WITH NO_INFOMSGS, ALL_ERRORMSGS;

The third command repairs the database.

DBCC CHECKDB (stellardb, REPAIR_REBUILD)

The last command sets it back to multi-user mode.

ALTER DATABASE stellardb SET MULTI_USER;

Restore only a Single Page

If only a single page is corrupt, you can restore that page. To do this, in the SQL Server Management Studio (SSMS), go to the Object Explorer and select Tasks > Restore > Page.

You need to enter the File ID and the Page ID. The Page ID is displayed in error message when you run the DBCC CHECKDB command and the File ID can be found in the following query:

SELECT name as FileName, file_id AS FileID
FROM sys.database_files;

On the Restore Page, press the Add button and enter the File ID and the Page ID. Then, press OK.

What to do if the above solutions do not work?

If the previous methods do not work, then you can use a powerful SQL database repair tool such as Stellar Repair for MS SQL. This tool is designed to fix corrupted databases. To repair the database, you need to first take the database offline. You can use the following T-SQL commands to take your database offline:

ALTER DATABASE stellardb SET OFFLINE;

Next, launch the software and look for the database file you need to repair. You can find the data file using the Find button.

Optionally, you can recover deleted rows by checking the Include Deleted Records option. Once the database file is selected, press the Repair button.

Once repaired, you can save the data in a New Database, in an existing database (Live Database), or in other formats, like Excel, CSV, etc.

Conclusion

Above, we have discussed how to detect the error 832 and different ways to fix the error. The easiest way to fix this is by restoring the database from backup. You can try the DBCC CHECKDB command to repair the database if you do not have a backup. Restoring a single page can be a valid option if only a single or few pages require fixing. If none of these solutions works, you can use Stellar Repair for MS SQL to repair the corrupt database.

Related Post

Exit mobile version