How to Repair and Rebuild SQL Database Manually

March 6, 2019 | Views: 635

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Applications working on SQL database platform are easy to use but they have risk of data loss because of SQL MDF File. Despite Database Administrator maintains the SQL database it is prone to corruption as it is highly affected by external factors. Operating system errors, abrupt system shutdown and changes made by user affect the SQL database, so one should be ready to deal with such errors and to repair the SQL database.

Here are two free methods to repair corrupt SQL and rebuild damaged database without any error. Follow, the below methods to retrieve the data and fix SQL Errors

Fix SQL Errors with DBCC CHECKDB 

  • Open the SQL Database and then go to console
  • Type the command DBCC CHECKDB ‘Database Name’, to check database status
  • Check the database index, if the index ID is greater than 1 than recreate it
  • If the Index ID is displayed with values O or 1 then type the following commands for recovery
    • DBCC CHECKDB (Name of Database repair_fast)
    • DBCC CHECKDB (Name of Database repair_rebuild)
    • DBCC CHECKDB (Name of Database repair_allow_data_loss)
  • Replace Name of Database with your database name. In this way, you can repair and rebuild the SQL database without any errors.

Repair SQL Database with Server Management Studio

  • Check the version of SQL you are using and then download the SQL Server Management Studio, you are using
  • Install and start the SQL Studio to run query
  • Now Run the commands in order as given
    • EXEC sp_resetstatus [Database Name]
    • DBCC checkdb ([Database Name]), here enclosed the database name with brackets.
    • DBCC checkDB ([Database Name]), REPAIR_ALLOW_DATA_LOSS
  • Execute the command and check database status. The file will open without any errors and SQL database will get repair.

These methods enable Database Administrators to fix the SQL issues and repair corrupt MDF files instantly. DBA should act immediately to prevent the database from further loss and these methods will help out.

Share with Friends
Use Cybytes and
Tip the Author!
Share with Friends
Ready to share your knowledge and expertise?
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge



Is Linux Worth Learning in 2020?
Views: 745 / December 14, 2019
How do I Get MTA Certified?
Views: 1316 / December 12, 2019
How much does your PAM software really cost?
Views: 1753 / December 10, 2019
How Do I Get into Android Development?
Views: 2143 / December 8, 2019

We recommend always using caution when following any link

Are you sure you want to continue?