How to Fix SQL Database Corruption manually?

Rate this post

In this article, I am going to tell you the various solutions through which you can repair MDF files which are found in the SQL Database. If the whole SQL Server is corrupted then you can fix SQL database corruption through the manual tricks which I am going to tell you. They are easy to follow and I will describe each and every step in detail so that a novice user can also apply them on their corrupted SQL Database.

Before I should discuss the measures to resolve SQL corruption, we should know the various reasons behind SQL Database Server Corruption. We can also avoid corruption issues if we know various reasons.

Reason for SQL Database Server Corruption.

  • Sometimes a user overwrites the file on the existing MDF file. This is the main cause of corruption. It increases the file size and the risk of corruption is high.
  • Making too many attempts to unlock the SQL Database can lead to corruption. Sometimes it happens that the user forgets the SQL password and he starts making random attempts. This can lead to SQL Server Corruption.
  • Failure in Flash Drive or Disk drive can also lead to corruption of whole SQL Database because this storage has some connection with the SQL Server.
  • At some point the configuration of the SQL Database makes it corrupted. It starts working against the database and disables the access on MDF files.
  • Virus infection can damage the whole SQL Database files and this leads to corruption issues. You can fix it but it may cause some data loss as well.
  • The internal bugs present on the SQL Database can be harmful to MDF files. They make the MDF files corrupted which makes the whole SQL Server corrupted.

You May Also Read- Tips to Prevent Corruption

Hassle-Free Solution

Download Free SQL Database Recovery to Repair Corrupt SQL Server Database & Restore SQL data from corrupt MDF files

6 Methods to fix SQL Database Corruption

Use SQL Management Studio Express

  • Download SQL Management Studio Express depending upon SQL version.
  • Go to Start and in Programs open MS SQL Server.
  • Now open SQL Database Management Studio Express.
  • By using Windows Authentication log into SQL Database.
  • Expand Database and Right-Click on wt_sched.
  • Select Properties and go to Options.
  • At the Bottom of the pane change Restriction Access to SINGLE_USER.
  • Click OK and repeat step 5 for wt­_Master
  • Select the toolbar and paste these two commands

dbcc checkdb(‘wtMaster’,REPAIR_REBUILD)
dbcc checkdb(‘wt_sched’,REPAIR_REBUILD)

  • Then Click on Execute to repair SQL Database file corruption
  • Change the Restriction Access from SINGLE_USER to MULTI_USER as you have done earlier.

Note*- Make sure that no Webtrends Services are started before you follow these steps.

 

Rebuild Wizard Method

  • Open Rebuild Master in BINN Directory found in the Tools tab of MS SQL Server.

 

  • Browser the SQL Server from the saved location and Click on Rebuild.
  • Confirm the Building process by clicking on OK.
  • Now Start SQL Server in SINGLE_USER
  • Open Command prompt and type exe –c –m.
  • From a backup, restore the master database or with the help of Query Analyzer or SQL Enterprise Manager
  • Once you restore the master database close the SINGLE_USER mode and Restart SQL Server in NORMAL Operation Mode.

The above technique can easily fix SQL Database corruption. If you are still unable to fix the problem then you can try the next measure.

DBCC CHECKDB Repair Option

  • Run DBCC CHECKDB command on the corrupt database.
  • See the index id.

If the index is greater than 1- Drop and Recreate it

If index is 0 or 1- re-run DBCC CHECKDB with suitable repair options such as repair_fast, repair_rebuild,  repair_allow_data_loss

The above tricks will help you to repair corrupted SQL Database server. If these steps won’t work then you can try the next method.

 

Try SQL Database Management Studio

  • Install Database Management Studio.
  • Click on New Query once you connect it to the Database.
  • Paste the script mention below in the New Query.

  • Click on Execute.

 

Recreate MDF Files

  • Stop SQL Server Instance and Copy the MDF and LDF files on different locations
  • Erase the original MDF and LDF files.
  • Start the SQL Server Instance and create a New Database.
  • Overwrite new MDF and LDF files.
  • Now put your server in EMERGANCY mode and SINGULAR mode.
  • Type the below-mentioned code and Execute DBCC CHECKDB.

DBCC CHECKDB (databaseName, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS

Now you can view the MDF file present on the SQL Database. But the overwrite techniques will not repair all the files. So for that, you have to go for a third party professional repair tool to fix SQL Database Corruption.

SQL Data Recovery Tool

SQL Database Recovery is a professional tool by Data Recovery Solution which helps to repair Corrupt SQL Database and retrieves all the data from the corrupt MDF file. There are two recovery modes in this tool. The standard recovery mode is for minor corruption and the Deep Recovery Mode is for severe corruption.

Features

  • The integrity of data is maintained.
  • Saves data in the user defined location.
  • Previews repaired file before saving.
  • Repairs and Recovers all SQL Database Server Files.
  • Compatible with SQL Server 2016, 2014, 2012, 2008, R2, 2008, 2005.

Conclusion

Well, I have told you the various methods through which you can easily repair SQL database corruption. You can either try the manual solutions or the paid ones. The manual methods are time taking and they are risky too. On one side they can repair MDF files but on the other side, they can cause the complete deletion of MDF files from the SQL Server. So take an effective decision.

I hope you liked this article.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *