Without a doubt, Microsoft SQL Server is the most widely used relational database management system for storing and retrieving data. Two types of database files are supported to store their data i.e. MDF (Primary Database File) and NDF (Secondary Database File). It has a log file with the extension .ldf, which is a transaction log file. However, some disadvantages are also associated with SQL Server. Sometimes users experience Microsoft SQL Server error 5172 – The file size property is incorrect and does not know how to resolve it. To fix this error, we have comes with the successful solution here to fix SQL Server header error 5172. Read on for a 100% working and safe solution.
Microsoft SQL Server Error 5172 – The File Size Property Is Incorrect
SQL Server stores its physical data in the primary database file, which contains the data by pages. The header information of a .mdf file is stored by the first page, called a header page. This page contains the important information of this database file like file size, signature, etc. When a user attempts to attach the MDF / LDF database file stored on their system, a message box appears “The header for the “test.mdf” is not a valid database file header. The FILE SIZE property is incorrect. (SQL Server error 5172). It occurs when the header information of a .mdf file becomes corrupted.
Reason For SQL Server Header Error 5172
There can be several reasons for SQL database file header corruption such as:
- Corrupted or damaged log file or data file.
- If you try to attach a higher version of the SQL database server file to a lower version.
- A sudden power failure that affects the driver and controller.
- Failure to shut down the system or restart SQL Server.
Because of all these issues, SQL Server displays a “The file size property is incorrect” error that makes the database file inaccessible.
Read More– How to recover SQL database from suspect mode?
Manual Solution to Fix 5172 Error in SQL Server
To resolve the SQL Server error 5172, you can use the backup of the SQL Server database and restore the data from the backup. However, it may happen that the backup is also in the same location and a sudden power failure occurs, which can damage the SQL backup file. In this case, the below steps had to be performed to fix SQL Server header error 5172:
Step 1. First of all, stop the SQL Server instance.
Step 2. Copy MDF and LDF files to another location.
Step 3. Delete the original MDF and LDF files.
Step 4. Now, restart the SQL Server instance.
Step 5. Create a new database (DB) with the same DB name and file name.
Step 6. Quit SQL Server Management Studio.
Step 7. Overwrite newly created MDF and LDF files.
What if the Error Not Fixed After Performing Manual Method?
There is a possibility that the manual process mentioned above does not resolve Microsoft SQL Server error 5172 – The File Size Property Is Incorrect. If the user does not have a backup of the SQL Server database, he/she is unable to execute the manual method. To resolve all these issues and resolve SQL database file header corruption without backup, you must opt for an automated solution.
One-Stop Solution to Fix SQL Server Header Error 5172
To rapidly resolve this error, you can take the help of the SQL Repair Tool. This will let you fix Microsoft SQL Server error 5172 header issue without backup. Using this utility, you can recover corrupt MDF file and NDF file with all database components like table, views, indexes, stored procedures, etc. It supports all versions of SQL Server including 2019, 2017, 2016, 2014, 2012, 2008, and others. The tool helps to recover SQL Server Database from MDF file and restore data into the live SQL Server database or Compatible SQL Script.
The MDF file recovery software can recover deleted records from SQL Server table and display the preview in red color. It allows you to restore SQL Server database to a new database or an existing database without any issue of data loss. The tool is capable to fix the header for file is not a valid database file header error and gives you 100% reliable and quick result.
Procedure to Resolve SQL Database File Header Corruption
Steps to fix SQL Server header error 5172 using the SQL Repair Tool are as follows;
Step 1. Launch the software. Click the Open button and select the MDF file which is corrupted.
Step 2. Choose the Scan Mode option from Quick and Advanced. Select SQL Server .mdf file version. If you want to view the deleted records, check the “Preview Deleted Records” box.
Step 3. Now, the tool displays the preview of recovered database items after the scanning process. You can see the deleted records in red color.
Step 4. Click the Export button and export the MDF file to SQL Server Database or SQL Server Compatible SQL Scripts.
Step 5. Export MDF file with schema only or schema & data both. In the end, click the Export button.
This blog described the whole solution of how to deal with Microsoft SQL Server error 5172. Here we explained the manual approach for fixing this error using the backup. If users do not have a backup of their SQL Server database. We mentioned the automated solution that can fix SQL Server Header Error 5172 – The FILE SIZE property is incorrect without backup. You can choose any of the methods to resolve SQL database file header corruption issue that meets your needs.