Home 0P3N Blog How to Repair and Rebuild SQL Database Manually
Ready to Start Your Career?
Create Free Account
sandycullens profile image
By: sandycullen
March 6, 2019

How to Repair and Rebuild SQL Database Manually

By: sandycullen
March 6, 2019
sandycullens profile image
By: sandycullen
March 6, 2019
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 ErrorsFix 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]
    • ALTER DATABASE [Database Name] SET EMERGENCY
    • DBCC checkdb ([Database Name]), here enclosed the database name with brackets.
    • ALTER DATABASE [Database Name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    • DBCC checkDB ([Database Name]), REPAIR_ALLOW_DATA_LOSS
    • ALTER DATABASE [Database Name] SET MULTI_USER
  • 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.
Schedule Demo

Build your Cybersecurity or IT Career

Accelerate in your role, earn new certifications, and develop cutting-edge skills using the fastest growing catalog in the industry