How to fix SQL database corruption after power outage

Introduction:

Sometimes due to the power outage or power shortage, we have to face some hardware or software issues regarding our system (computer). And when you log in again on the system afterward, you see that your most important SQL Server database data is not available. This database is so important to you that your all business accounting and financial records saved in it. One and only one solution remains when he/she has to face this kind of problem. And this solution is to reboot the system many times, sometimes it works, but the working probability of this solution is too low. And system always shows the disputable message that the database not found or corrupted. And sometimes you contact the service provider, and they said this software version is no longer supported. We will show some scenarios through which we can solve this corruption issue. After these scenarios and at the end of this article I will suggest you a software which will solve all your problems with only one to two clicks.

Power out problems

Depending on your production environment, you may have some Power out problems due to this, the server may be shut down, and the database can be corrupt. For this scenario, try to have a UPS for your server or a battery backup system.

Backups

While searching for a solution, the first solution is to have a recent backup of your most important database if you have this one then don’t worry about it. Your SQL server is smart enough to tackle this of problems. It automatically recovers your corrupted database with the help of SSIS or some scripts and saves your entire database but, in case if you have no recent backups now this time you should worry about that you are going to face a huge loss because your database has all kind of transaction and financial records of your business.

Torn Page detected

What is Torn page?

It is a setting to detect database corruption in SQL Server.

It detects failures related to I/O headers that try to access a page that has miswritten to the disk. It reports an I/O message an error (torn page) detected throughout the reading.

Afterward, while searching for a solution when you have no recent backups for your database. You can take a copy of MDF and LDF

Hex editor:

What is the hex editor?

A hex editor allows checking the manipulation of the elemental binary information that constitutes a data file. There are several hex editors on the web that are free like UltraEdit, HxD, BVI, etc.

You find that a table sys.allocation_units which was the part of your database. You can use the hex editors to verify the data corrupted and using the page number edit the data and fix it:

Proposed Solution:

Detach the repaired database from the failing environment. Copy the MDF and LDF files back to the customer’s environment. Recommended scripting the entire database with data and recreating to get it back to a safer position.

Another way to repair is by using the T-SQL commands. You can use the DBCC CHECKDB to check consistency errors in the database and also you can repair your database.

For more information about the DBCC CHECKDB commands, please refer to this link: DBCC CHECKDB (Transaction-SQL)

Alternative Solution:

As I told you at the start of this article that I will suggest you a software which will solve all these kind of problems with only one to two clicks. This software name is Stellar Repair for MS SQL. It repairs corrupt MDF and NDF files and maintains the database integrity.

This SQL Database Recovery Software provides powerful and distinctive options that will address and repair all types of corruption from the SQL database.

The software has excellent features to repair the corrupt MDF and LDF files. It also recovers the modules of databases such as the table’s keys, stored procedures, etc. The beauty of this software is that even you can recover the deleted records from your SQL database.  This software allows a user to save the repaired SQL database in different formats like MS SQL, HTML, CSV, and XLS formats. It supports more than ten versions of MS SQL.

  • While launching this software, the window will look like this.
  • Press Browse to select the corrupted MDF file:
  • Click Repair to start the repairing process
  • After completion, this message popups. Press OK:
  • Now save the file.

The software will repair the database and all the information will be restored.

Conclusion:

In this article, we talked about the most common scenarios to recover a database corrupted due to a power outage. These scenarios are faced by SQL DBAs which is related to database corruption. This type of SQL recovery software can play an important role to fix database corruption. Just try it and you will have a pretty nice experience.

The following two tabs change content below.
Priyanka
Priyanka Chouhan is a technical writer in Stellar Data Recovery with 9 years of experience and has written several articles on SQL server & SharePoint. In the spear time, she loves reading and gardening.

Leave a Reply