SQL Server Error 823 Explained and Resolved

  author
Rollins Duke   
Published: June 28th, 2023 • 6 Min Read

The Microsoft SQL Server is many organizations’ go-to solution for housing critical data or supporting essential operations. Therefore, when DBAs get an alert for SQL Server error 823, it becomes a concerning situation.

Moreover, if the error is not resolved in time, it can wreak havoc on the day-to-day operation of the business. However, users don’t need to worry as this article delves into the causes and contains complete knowledge to overcome this error. Let’s start with the causalities.

Reasons to Encounter SQL Server Error 823

This fatal error results from a faulty API call during input or output operations on the SQL Server. Microsoft designed the SQL Server to perform functions like ReadFile, WriteFile, etc via Windows APIs. After sending an API call next task that the server is responsible for, is to check for errors. If any errors are found, the following message is displayed for the user:

I/O error <ERROR> detected during <I/O OPERATION> at offset <OFFSET> in file <FILE_NAME>

Here is a brief explanation of all the parts of this error:

  • ERROR: It is a number that refers to the type of error. The number helps to distinguish between the root cause, which is either Operating System oversight or Input Output failure.

If the error pertains to an I/O operation, the failure message within the parentheses may correspond to one of the following descriptions:

    • Low bytes transferred: It directs to a situation where the Windows API was executed correctly, but an incorrect or insufficient number of bytes were transferred.
    • Bad page ID: It means that there is a mismatch between the page ID specified in the header and the expected page that is present in memory.
    • Torn page: This message is shown by the server when the page is broken or exhibits corruption issues.
  • OPERATION: It refers to either read or write mode API calls while discussing  SQL Server error 823.
  • OFFSET: The physical byte offset provided here represents the distance in bytes from the beginning of the file. To determine the logical page number impacted by the error, users can divide the hexadecimal offset number by 8192.
  • FILE_NAME: This is nothing but the file name affected by the error.

Don’t worry as there exists a professional solution to this problem.

Fix SQL Server Error 823 Using the Automated Solution 

When it comes to SQL Server error resolution, there is only one unrivaled leader, the SQL Recovery Tool from BitRecover. This all-inclusive software offers a user-friendly interface for efficiently managing all SQL Server database issues. 

Download Now Purchase Now

Additionally, it has robust error diagnosis, and performance optimization functionalities, all within a unified package. Users can easily familiarize themselves with the tool by following the straightforward steps outlined below.

Step-1. First of all, obtain, set up, and launch the software on your Personal Computer.

Launch the tool

Step-2. Then, select the MDF or NDF file from the left-hand side menu in the tool.

Select The File

Step-3. Opt for the Advanced Scan feature to comprehensively recover the file.

Choose Advance Scan

Step-4. Customize the output settings to suit your specific preferences.

Customize Output Settings

Step-5. Specify the destination for the file and click on “Export”.

Export the File

By utilizing this advanced software users will be able to shield their database from any potential pitfalls. Therefore, users should not waste any more time scratching their heads and go with the expert-recommended solution. We also have some manual techniques for those, who have complete knowledge of SQL queries or those who address themselves as experts.

Manual Mechanism to Resolve Operating System Error 

Users will get an operating system error message in the following format:

Error: 823, Severity: 24, State: 2.

2023-03-06 20:45:15.00 spid58 The operating system returned error 1117 (The request could not be performed because of an I/O device error.) to SQL Server during a write at offset 0x0000002d450000 in file ‘e:\program files\Microsoft SQL Server\mssql\data\UserDatabase.mdf’. 

First, use the DBCC CHECKDB command to ensure that a particular database is the main culprit of this issue. If the DBCC command does not return any alerts, it means that SQL Server error 823 is mainly due to other reasons, such as hardware failure. In that case, it would be more beneficial to directly, contact the hardware manufacturer to sort out the problem.

I/O Logical Check Failed Error Resolution

In case an error message is of the form: 

2023-03-06 20:45:15.00 spid66 Error: 823, Severity: 24, State: 22023-03-06 20:45:15.00 spid66 I/O error (bad page ID) detected during a write at offset 0x00000016774000 in file ‘h:\sql\MSSQL\data\TemporaryDatabase.mdf’.

Step-1. Identify the affected database and file by execution of the given command:

DBCC CHECKDB WITH ALL_ERRORMSGS

Step-2. The next step for resolving SQL Server error 823 is, to take a full backup of the entire database. Users can use the following SQL query to do this task.

BACKUP DATABASE [UserDatabaseName] TO DISK = 'C:\Backup\UserDatabaseName.bak' WITH INIT, FORMAT;

Step-3. Then, Use the DBCC CHECKDB command to check the database’s integrity.

Step-4. At last, restore the affected pages from a clean backup if available.

Consider using the specialized database recovery tool mentioned in the above section if the issue persists.

Best Practices to Avoid SQL Server Error 823

Some of the community guidelines that users must follow to maintain the health of their SQL Server are as follows:

  • Backup Regularly: If the users ensure consistent backups of their databases on a fixed schedule, they will have the option to restore data in case anything goes wrong.
  • Monitoring Storage: Users are recommended to keep an eye on the disk space they have for I/O operations. As it allows them to prevent problems that arise from incorrect API calls.
  • Update Hardware: Outdated hardware is one of the major causes of SQL Server Errors. Therefore, it is in the user’s best interest to keep their hardware in good condition.

Note: In case some users cannot get into their SQL Server, the reason might be a SQL Login Failed Error 18456.

To Sum It Up

Even for experienced DBAs, SQL Server Error 823 is not an easy foe to beat. From identifying its cause to finding a long-lasting solution, every step poses a new challenge. But with the automated utility provided here, and by following the guidelines to maintain SQL Server, users will have a resilient database.