SQL database corruption is the issue every database admin has to face at some point in their lifetime. But do you know what can cause you more trouble than a corrupt database? It is the misconceptions around SQL database corruption. These myths can actually worsen the situation for SQL database and its users. Therefore, it is crucial that users have the full knowledge of SQL Database corruptions and the myths and reality surrounding it.
Some Common Myths Regarding Database Corruptions
Let’s explore which ideas about database corruption are basically misconceptions.
- Server Restart/ Reboot is the Quickest Method to Fix Corruption: This is one of the most prevailing misconceptions about SQL database corruption. SQL Server reboot or Windows Server restart will not fix the corruption, rather, it will possibly make the situation worse by putting it in Suspect mode. Detaching a database that is already in Suspect mode will make it impossible to fix the corruption ins future. A corrupt database page requires repairing or restoration, not reattaching.
- Detaching and Re-attaching the Database will Resolve Corruption: This is another malpractice performed by many database admins. Instead of repairing, it will make the database recovery more difficult.
- Repetitive Running of DBCC CHECKDB will Do Away With All Corruptions: In some extremely rare cases, re-running the DBCC command may repair one or two minor level corruption from SQL database. But this is not a recommended solution as the chance of success is very rare.
- Applying Repair Command is harmless: If you believe that running commands to repair will not cause any harm to your database, you are wrong. If you are running DBCC CHECKDB REPAIR_ALLOW_DATA_LOSS, it is possible that your database may face some significant amount of data loss. So, always keep a backup of your database to avoid this sort of situation.
- To Execute Repair Commands, DBCC CHECKDB is Not Required: No, DBCC CHECKDB commands are used for the purpose of checking physical and logical integrity complete set of objects of any particular database. Before and after running the database repairing command, users have to run DBCC CHECKDB. It is not possible to repair database using manual command without running DBCC CHECKDB.
- Running Repair Command Alone Assures Corruption Removal: Wrong! The success of Repair command in order to corruption removal depends on many factors. For this reason, its result will vary depending on the severity of the damages done to the database. So, it is mandatory to run DBCC CHECKDB command after repairing. It will help users to find out more critical corruptions and confirm the success of Repair command.
- Incomplete Lengthy Operations Lead to Corruption: Many of us believe that if an operation is going on for a long period of time, interrupting it halfway will cause damage to the database. This is not true at all. Database corruption occurs only when there is a physical level corruption (e.g. bug, virus) in the Server.
- DBCC CHECKDB is All-In-One Solution for All Corruptions: This is not quite the scene. The Repairing command of DBCC CHECKDB has only the limited capability when it comes to fixing corruption from SQL database. There are many corruptions that repair command is unable to fix, like PFS Page header corruption, Metadata corruption, Common value corruption, etc. If used in case of these corruptions, it will end up extract data in a lengthy process with no result. Moreover, REPAIR_ALLOW_DATA_LOSS command often leads to data loss. Restoration from last good backup is the most useful method in such cases.
Conclusion
There are numerous misconceptions around SQL database corruption in the industry. Here, we have focused on some of the most common myths regarding database corruption in SQL Server. We expect that the users will gain knowledge from this post and be able to take the right decision once the database becomes corrupt. SQL Server experts recommend having a regular backup of the entire database to avoid inconvenience during database corruption. In case any corruption persists in the database, then one can use SysTools MDF Recovery tool to repair corrupted MDF/NDF File of SQL version 2017, 2016 & all below versions.