SQL Logical Consistency-based I/O Error: Troubleshooting Guide
SQL Server from time to time generates SQL Logical Consistency-based I/O Error. This article will elucidate why this problem occurs and provide a manual and professional method.
SQL Logical Consistency-based I/O Error in SQL Service ERRORLOG
This note decides you must fix SQL Logical Consistency-based I/O Error in the database.
Reasons For SQL Logical Consistency-based I/O Error
The main reasons that cause the SQL Logical Consistency based I/O Error
Hardware issues like disk controller, and data storage are the main reasons for the SQL logical consistency I/O error.
Overheating of the system Hard disks and data cables can also cause SQL logical I/O errors.
The abrupt shutdown/collapse or forcing an unresponsive computer to shut down is responsible for SQL logical consistency I/O error.
The Viruses, Bugs, and Faults in System Software can also be responsible for SQL logical consistency I/O errors.
Sometimes the SQL admin attempts to execute commands or modify the SQL Server database structure.
The file system architecture of the SQL Server shows discrepancies due to which SQL logical consistency I/O errors occur.
You can try the following methods to fix this error and restore the database.
Restore the Database from Backup
The simplest way to address this problem is to restore the database from the last backup and replace the corrupt one. You could use the following code T-SQL to restore the database.
RESTORE DATABASE SYSdb_name FROM DISK = 'e:\backups\SYSdb_name.bak' WITH REPLACE;
The code above will restore the SYSdb_name database, which is located in the path e:\backups\SYSdb_name.bak. You can alter the database name within the code.
Instead, you can restore the database through the SSMS user interface. These are the steps.
Select Object Explorer, right-click on Databases, and choose Restore Database.
Choose the Device option, press the Browse button, and choose the backup file to restore the database.
On the Selections page, choose Overwrite the existing database (WITH REPLACE). By doing so, replace the SQL Server database with logical consistency-based I/O error with the backup.
Using the DBCC CHECKDB Command
If you find yourself without any database backup, you have the option to use the DBCC CHECKDB command. The command can repair the database if it is corrupt. Follow the below steps
Fixed database in emergency mode using the below command
ALTER DATABASE db_data SET EMERGENCY;
Now, use the below to turn the database into a Single-User mode
ALTER DATABASE db_data SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
To repair the database, use the DBCC CHECKDB command with the REPAIR_REBUILD option. Or else use the REPAIR_FAST or REPAIR_ALLOW_DATA_LOSS.
DBCC CHECKDB (da_data, REPAIR_REBUILD) WITH NO_INFOMSGS, ALL_ERRORMSGS;
In the end, set the database to multi-user mode
ALTER DATABASE db_data SET MULTI_USER;
Restore the Damaged Page of the SQL Server
If this is a single page that is damaged, you can restore that page from the backup. This is generally used for large databases, For this use SSMS and follow the steps
In the Object Explorer, right-click the database and select Restore>Page.
Press the ADD button option and write that contains the error and the page ID with the problem. Then press OK.
You can find the Page ID when you run the DBCC CHECKDB COMMAND. It will show you the Page ID AND page IDs with errors.
To get the File ID, use the following command.
SELECT name as Filename, file_id AS File ID FROM sys.database_files;
Limitations of Manual MethodThe manual process takes a lot of time to process the data files and may not be available for the urgent need.
Using REPAIR_ALLOW_DATA_LOSS may resolve the SQL Logical Consistency-Based I/O Error, but it may lose some data information.
The technical in-depth knowledge of SQL Commands is needed to execute the process.
It does not work for faulty pages present in the non-clustered index of the SQL.
The most effective software for resolving these issues is the SysTools SQL Recovery Tool. It repairs and restores all the SQL Server database files and records without losing the integrity and data information of the SQL database. The software is consistent with all the versions of MS SQL Server. It resolves many types of corruption in SQL Server. The tool exports the data files in a CSV File Format effectively.
Steps to follow
Download, install, and execute the Software application to your system.
Now Open to select the MDF and NDF files in the system software.
Choose the types of Scan mode i.e. Quick Scan or Advance Scan as per your needs.
Select the Export types such as SQL Server Database, SQL Server Compatible SQL Scripts, and CSV File Format.
Now enter the location and file path to proceed further.
Hit the Export button to save and view as per your requirements.
It supports all the versions of MS SQL Server database like 2022, 2019, 2017, 2016, 2014, 2012, 2008 R2, 2005, and 2000 versions.
The tool completely recovers data files from malware-affected and SQL Injection techniques MDF files.
It repairs all the key objects of the SQL Server such as Tables, Functions, Rules, Stored Procedures, Views, Triggers, and all the keys including the Primary Key and Secondary key.
The software offers two types of scanning modes. Quick Scan for regular database errors and Advance Scan for High and severe corruption database files.
The software application recovers the primary and secondary files(MDF and NDF files). It recovers all the deleted data files and records as well.
Supports all the versions of Windows Operating Systems like 11, 10, 8, and 7 with the support of 32-bit and 64-bit versions.
Export the particular objects from the primary and secondary database files. It includes items like rules, views, etc.
The tool enables to export of the database with only the schema of chosen records. Users can export all objects with both schema and data in it.