Are you facing "SQL Server Error 5172" , SQL Error 5173 , SQL Error 823 , or SQL Error 5181?
Just recently, one of our customer contacted us regarding fixing this error. This article will guide you on how to go about it.
Here at Ibmi Media, we regularly handle numerous SQL related errors for our customers as part of our Server Support Services.
In this context we shall look into more about this error and how to get rid of it.
Data is stored in a primary database file arranged according to pages in an SQL server. The initial page contains the header information of the .mdf file referred to as the header page.This page house all the vital information of the database.
Sometimes when a user tries attaching the MDF/LDF database file, an error message which looks like listed below appears;
The header for file ‘test.mdf’ is not a valid database file header. The FILE SIZE property is incorrect. (SQL Server Error 5172)
This results when the header information of the .mdf file is corrupted and makes the database inaccessible.
The main factors responsible for this error includes;
i. Virus attacks on the database.
ii. When the hardware is not working properly.
iii. As a result of not shutting down or rebooting the SQL Server or system correctly.
iv. SQL database version inconsistency can trigger this issue especially when a higher version is used which is not compatible with the lower version of the SQL database server.
v. Power failures which occur suddenly can lead to drivers and controllers not working efficiently.
vi. As a result of corruption of the Logfile or data file.
Different approaches can be applied in fixing this error just as outlined below;
Restoring the corrupted database from a recent database backup
You can follow the following steps to restore from a backup file;
i. To begin, Stop and exit the SQL Server Instance which is currently running.
ii. Then copy the MDF and LDF file to a different location on your computer.
iii. Next, delete the MDF and LDF files and start the SQL Server Instance again.
iv. You can now create a new database with the same name and filename as previously used. Afterwards, stop the SQL Server.
v. Now, for online database recovery, do overwrite MDF and LDF data files.
Alternatively, You can use some SQL Database Recovery repair tools such as the professional Kernel to recover, and restore corrupted MDF files in the SQL Database Server. These kind of tools supports large data files and are very helpful in recovering database objects like functions, tables deleted records, tables and more.
Finally, using a compatible version of database and SQL Server to resolve this error.
SQL Server Error 5172 can be triggered when trying to attach an MDF or LDF database file on the machine.