Bobcares

SQL error 5172

by | Sep 7, 2020

Are you trying to resolve the error ‘SQL error 5172’? We can help you in resolving it.

Here at Bobcares, we have seen several such SQL related issues as part of our Server Management Services for web hosts and online service providers.

Today we’ll take a look at the cause for this error and see how to fix it.

 

More about SQL error 5172

The SQL server stores all its data in a primary database file. It contains the data according to pages.

The first page contains the header information of the .mdf file. So it is known as the header page. This page contains all the important details of the database.

Usually, when any user tries to attach the MDF/LDF database file present on his/her machine, a message pops-up as below

“The header for file ‘test.mdf’ is not a valid database file header. The FILE SIZE property is incorrect. (SQL Server Error 5172)”.

Here the error message says  “.mdf file not being a valid database file header”. This happens when the header information of .mdf file corrupts. As a result, the database becomes inaccessible.

 

What causes ‘SQL error 5172’ to occur

Here are the different causes of this error to occur.

  • Logfile or the data file is damaged or corrupted.
  • A sudden power failure causes the drivers and controllers to get affected.
  • Trying to attach a higher version of SQL database server files to a lower version of the SQL database server.
  • Improperly shutting down the system or SQL Server reboot.
  • Hardware Malfunctioning
  • Any sort of virus attacks

 

How we fix the error ‘SQL error 5172’

Here are the different solutions provided by our Support Engineers to resolve this error.

1. Manually fix by restoring from a recent database backup.

One of the best ways to get rid of this error is to restore from the backup files. Here are the steps to do the same.

  1. First, exit from the running SQL Server Instance.
  2. Next, copy the MDF and LDF files into some other location on your current machine.
  3. Then delete the MDF and LDF files and start SQL Server Instance once again.
  4. Now create a new database with a similar name and filename. After that, stop the SQL Server.
  5. Finally, overwrite MDF and LDF data files for online database recovery.

In some cases, this error occurs when a higher version database file is attached to a lower version Server. So, ensure that the database file is attached to the right version.

 

2. Automated Solution

The easiest solution is to make use of any third party automated solution. You can consider the professional Kernel for SQL Database Recovery tool to repair, recover, and restore corrupt MDF files back to SQL Database Server.

These tools help in recovering all database objects such as functions, tables, rules, functions, deleted records, and so on. Also, you can recover large data files.

 

3. Get an MDF and LDF file from any other server which has “exactly” the same version of SQL Server. This might lead to losing some data from the previous model database and will get it from another server.

[Need any further assistance in fixing SQL errors? – We’re available 24*7]

 

Conclusion

In short, this error arises when any user tries to attach the MDF/LDF database file present on his/her machine. Today, we saw how our Support Engineers fix this SQL error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.