A Solution to Resolve Microsoft SQL Server Error 5172

Lindsey Smith | June 4th, 2018 | MS SQL

Drawbacks such as complexity and lengthy nature of database management system are one of the reasons for making database prone to corruption. Microsoft SQL is one of the most preferred choice amongst Relational Database Management System Administrators but this factor does not help in overcoming its drawback such as error 5172 the header for file not valid. Like other RDBMS, SQL Database also hit corruption and one of these is SQL server error 5172.

error 5172 in SQL server

The above senario depicts the case of MS SQL server error 5172. Similar types of errors can be encountered by any user. In the following article, causes and solution of error 5172 in SQL server are taken into the consideration. The basics of Database File Header page, its effects, possible causes and appropriate solutions are listed below for better understanding.

Database file Header Page:

In SQL server, every database file contains a single page that contains information file itself and is called file header page. These are numbered sequentially starting from 0 for the first page in the file. The file header page contains the information about the attributes of each file having unique file ID number.

Extension .MDF and .NDF are used to store SQL data files and the disk space logically distributes itself into pages numbering 0 till n. All disk Input-Output related operations are done on pages. In a nutshell, SQL server reads and writes whole data-pages. Structure of SQL server data file is depicted below.MS SQL server error 5172

Page 0 (Header):

It is the First page of the SQL data file and occupies approx. 8FB storage space and stores metadata about that particular SQL Data file. All files have Header as Page 0, which can’t be recovered by CHECKDB. If there is corruption in File Header then SQL server error 5172 occurs and the entire file is restored. Check Header contents with DBCC page. A better option is “DBCC FILEHEADER” also known as purpose command.


When SQL database DBCC FILEHEADER command is executed, it considers two parameters. The first is the database id or the database name and the second parameter is the file id. DBCC FILEHEADER can be used for log files too. As log files are not organized in pages, DBCC page fails if you attempt to access a log file with it.
DBCC FILEHEADER produces a single result indicating information about the database set as output.

Now, What is SQL Server Error 5172?

Some of the reasons for error 5172 the header for file not valid are listed below-
SQL File Header page plays an important role in the database and any corruption on this page directly affects the database to the extent that it is rendered dysfunctional. The outcome is “Corruption in Database” or “Malformed Database” or “Complete Inaccessibility of Database” in extreme cases. It is a fact that all SQL Administrators keep an eye of their database administration and remain alert 24×7; despite that unexpected reasons may lead to issue such as “the header for file is not a valid database file header. the pageaudit property is incorrect”:

  • Drivers and Controllers behaving badly
  • Unpredicted Power Outages
  • Abrupt Rebooting of SQL server

Corporates have a backup recovery plan in place but most of the time, it often fails to serve and MS SQL server error 5172 occurs.

How to Fix SQL Server Error 5172?

Manual Method to Deal with Error 5172 the Header for File

Almost all Corporates have a backup of their data hence, the best way to resolve MS SQL server error 5172 is backup data restoration. But there may be a situation where the backup is also taken at the same location and there is a sudden power outage, and this may result SQL backup file corruption. In that case, below-mentioned steps are needed to be followed:

  1.  Stop SQL Server instance
  2.  Copy MDF and LDF files to another location
  3. Delete original MDF and LDF files
  4.  Start SQL Server instance again
  5.  Create new database (DB) with same DB name and Filenames
  6.  Stop SQL Server
  7.  Overwrite newly created MDF and LDF

All the above-mentioned steps will lead to database recovery online. Establish an EMERGENCY or SINGLE USER mode for this database and execute DBCC CHECKDB as follows:

Note: There might be an opposite effect while Executing DBCC CHECKDB command, that is the user might end-up losing partial data with flags such as REPAIR_ALLOW_DATA_LOSS. Organization’s data is crucial and it should be available at its place and hence, a partial data loss may result in business loss.

Alternative Professional Tool to Solve SQL Server Error 5172

If the manual method is not working then in this condition a professional solution is preferred for SQL database file header corruption. The only and in fact the best way is to use SQL Recovery Tool, which provides the best way to protect the data. This software removes Database file header corruption in MS SQL without any data loss.


As RDBMS is most commonly used by SQL Database Administrators, it is prone to corruption and unexpected shutdowns. To overcome this problem, backup of the precious database is created at a different location so that there is an easy restoration. If this option is also useful at the time, use an alternate third-party software to deal with MS SQL error 5172 and recover your corrupted database in no time.