{"id":206,"date":"2022-01-14T09:14:26","date_gmt":"2022-01-14T09:14:26","guid":{"rendered":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/?p=206"},"modified":"2022-01-14T09:14:26","modified_gmt":"2022-01-14T09:14:26","slug":"sql-database-error-5172-the-page-control-property-is-incorrect","status":"publish","type":"post","link":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/sql-database-error-5172-the-page-control-property-is-incorrect\/","title":{"rendered":"SQL Database Error 5172 &#8211; The Page Control Property is Incorrect"},"content":{"rendered":"<h2 style=\"text-align: center;\">\u201cA case of header corruption\u201d<\/h2>\n<p>In this article, I present to you a case of database corruption. I am sure that anyone who has worked with SQL servers for a long time has had at least experienced one case where the database header got corrupted. Let me tell you that if you&#8217;ve had this problem, you will probably remember the error number: 5172.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-207\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/11.png\" alt=\"\" width=\"932\" height=\"141\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/11.png 932w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/11-300x45.png 300w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/11-768x116.png 768w\" sizes=\"(max-width: 932px) 100vw, 932px\" \/><\/p>\n<p>We will see together how to fix this type of error manually. And I must say that is not too easy. Often, for a manual recovery, it is necessary to know the internal structures of the mdf and ldf files.<\/p>\n<p>I want to anticipate that in this case it is much better to rely on a program specialized in data recovery, like <a href=\"http:\/\/www.stellarsqldatabaserecovery.com\/\">Stellar Repair for MS SQL<\/a>.<\/p>\n<p>Let&#8217;s start from the beginning.<\/p>\n<p><strong>What\u2019s the Error 5172? This error means that the database header is corrupt and contains one or more invalid values.<\/strong><\/p>\n<p>So, what is the header?<\/p>\n<p><strong>The Header<\/strong><\/p>\n<p>Trying to be as clear as possible, a SQL Server database consists of two or more physical files. There will be at least one file with the extension mdf (called primary) which contains the data and one file with the extension ldf which contains the transaction log.<\/p>\n<p>The files are split into pages that have a fixed size of 8 KB and are the basic unit of the I\/O operation.<\/p>\n<p>The first pages have special meanings. For example, page 0 is the header.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"163\">Page 0<\/td>\n<td width=\"279\">File header page<\/td>\n<\/tr>\n<tr>\n<td width=\"163\">Page 1<\/td>\n<td width=\"279\">Page 1 PFS page<\/td>\n<\/tr>\n<tr>\n<td width=\"163\">Page 2<\/td>\n<td width=\"279\">Page 1 GAM page<\/td>\n<\/tr>\n<tr>\n<td width=\"163\">Page 3<\/td>\n<td width=\"279\">The first SGAM page<\/td>\n<\/tr>\n<tr>\n<td width=\"163\">Page 4<\/td>\n<td width=\"279\">Not used<\/td>\n<\/tr>\n<tr>\n<td width=\"163\">Page 5<\/td>\n<td width=\"279\">Not used<\/td>\n<\/tr>\n<tr>\n<td width=\"163\">Page 6<\/td>\n<td width=\"279\">First DIFF mapping page<\/td>\n<\/tr>\n<tr>\n<td width=\"163\">Page 7<\/td>\n<td width=\"279\">First ML mapping<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Each page is then divided into a header and a body. The header of each page has a size of 96 bytes, the remaining space of 8096 bytes contains data and is called body.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-208\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/page.png\" alt=\"\" width=\"538\" height=\"364\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/page.png 538w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/page-300x203.png 300w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/p>\n<p>The header contains important information, such as the page type (m_type) that identifies what type of data the page will contain.<\/p>\n<p>For example, a value of m_type equal to 15 identifies a page of type header.<\/p>\n<p>Type this command:<\/p>\n<pre>DBCC TRACEON (3604)\r\nDBCC PAGE ('Empty', 1, 0, 3)<\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-209\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/m-type.png\" alt=\"\" width=\"766\" height=\"227\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/m-type.png 766w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/m-type-300x89.png 300w\" sizes=\"(max-width: 766px) 100vw, 766px\" \/><\/p>\n<p>Now that you know the theory, let&#8217;s see how to fix the database.<\/p>\n<h2><strong>Fix Corrupt Database Manually<\/strong><\/h2>\n<p>The scenario: Your client has no backup and has just sent you its two corrupt mdf and ldf files.<\/p>\n<p>You tried to attach the files with the following command.<\/p>\n<pre>EXEC sp_attach_db @dbname = N'Db_5172',\r\n@filename1 = N'C:\\scambio\\Db_5172.mdf',\r\n@filename2 = N'C:\\scambio\\Db_5172_log.ldf';\r\n\r\n<\/pre>\n<p>But you got this error:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-210\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/error-message.png\" alt=\"\" width=\"932\" height=\"141\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/error-message.png 932w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/error-message-300x45.png 300w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/error-message-768x116.png 768w\" sizes=\"(max-width: 932px) 100vw, 932px\" \/><\/p>\n<p><strong>Ok! We have the 5172 error: The header (page 0) of the ldf file is corrupted. <\/strong><\/p>\n<p>If you open the ldf file with a hex editor, you can see that the first part of it contains only zeros.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-211\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/hex-editor.png\" alt=\"\" width=\"1190\" height=\"146\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/hex-editor.png 1190w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/hex-editor-300x37.png 300w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/hex-editor-768x94.png 768w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/hex-editor-1024x126.png 1024w\" sizes=\"(max-width: 1190px) 100vw, 1190px\" \/><\/p>\n<p><strong>Well, the transaction log is gone!<\/strong><\/p>\n<p>In this case, the only way to recover the data is this:<\/p>\n<ul>\n<li>Create an empty database and then put it offline:<\/li>\n<\/ul>\n<pre>CREATE DATABASE Db_5172\r\nALTER DATABASE Db_5172 SET OFFLINE<\/pre>\n<ul>\n<li>Then, replace the files with the damaged ones.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-212\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/replace.png\" alt=\"\" width=\"801\" height=\"53\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/replace.png 801w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/replace-300x20.png 300w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/replace-768x51.png 768w\" sizes=\"(max-width: 801px) 100vw, 801px\" \/><\/p>\n<ul>\n<li>Now try to put the database online with the following command:<\/li>\n<\/ul>\n<pre>ALTER DATABASE Db_5172 SET ONLINE<\/pre>\n<ul>\n<li>You get the database attached but in Suspect Mode.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-213\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/recovery-pending.png\" alt=\"\" width=\"280\" height=\"114\" \/><\/p>\n<ul>\n<li>Now to repair a database in Suspect Mode, set the database in Emergency and Single User Mode:<\/li>\n<\/ul>\n<pre>ALTER DATABASE Db_5172 SET EMERGENCY;\r\nALTER DATABASE Db_5172 SET SINGLE_USER<\/pre>\n<ul>\n<li>And finally recover the database.<\/li>\n<\/ul>\n<pre>DBCC CHECKDB (N'Db_5172', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;<\/pre>\n<p>Without any other problem, you will have your data back. Obviously without the changes contained in the transaction log. The ldf file is damaged and will be lost.<\/p>\n<h3>Recover Database with Stellar Repair for MS SQL<\/h3>\n<p>Stellar Repair for MS SQL can effectively repair a corrupted database with 5172 error. The software will read all the data inside the non corrupted mdf file. The transaction log can be missed.<\/p>\n<p>Let\u2019s execute the Stellar Repair for MS SQL software.<\/p>\n<ul>\n<li>Just select the mdf file to recover.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-214\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/main-interface.png\" alt=\"\" width=\"523\" height=\"361\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/main-interface.png 523w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/main-interface-300x207.png 300w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/p>\n<ul>\n<li>Now press the Repair button.<\/li>\n<li>Choose the Advanced Scan option and press OK.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-215\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/scan-mode.png\" alt=\"\" width=\"511\" height=\"214\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/scan-mode.png 511w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/scan-mode-300x126.png 300w\" sizes=\"(max-width: 511px) 100vw, 511px\" \/><\/p>\n<ul>\n<li>The table is recognized.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-216\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/recovered-database.png\" alt=\"\" width=\"534\" height=\"252\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/recovered-database.png 534w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/recovered-database-300x142.png 300w\" sizes=\"(max-width: 534px) 100vw, 534px\" \/><\/p>\n<ul>\n<li>Press the Save button to save the recovered data in a new database.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-217\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/save-database.png\" alt=\"\" width=\"483\" height=\"284\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/save-database.png 483w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/save-database-300x176.png 300w\" sizes=\"(max-width: 483px) 100vw, 483px\" \/><\/p>\n<ul>\n<li>Insert the server name and the authentication mode and press the Next button.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-218\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/1233.png\" alt=\"\" width=\"485\" height=\"297\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/1233.png 485w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/1233-300x184.png 300w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/1233-223x137.png 223w\" sizes=\"(max-width: 485px) 100vw, 485px\" \/><\/p>\n<ul>\n<li>Choose the Standard Saving method and press the Save button.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-219\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/save-database2.png\" alt=\"\" width=\"484\" height=\"237\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/save-database2.png 484w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/save-database2-300x147.png 300w\" sizes=\"(max-width: 484px) 100vw, 484px\" \/><\/p>\n<ul>\n<li>The software will start to write the data into a new database.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-220\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/saving-tables.png\" alt=\"\" width=\"725\" height=\"167\" srcset=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/saving-tables.png 725w, https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/saving-tables-300x69.png 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/p>\n<ul>\n<li>At the end, you will find a new database named Recovered_Db_5172.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-221\" src=\"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-content\/uploads\/2022\/01\/recovered-db.png\" alt=\"\" width=\"256\" height=\"263\" \/><\/p>\n<p>I hope you will find this post useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u201cA case of header corruption\u201d In this article, I present to you a case of database corruption. I am sure that anyone who has worked with SQL servers for a long time has had at least experienced one case where the database header got corrupted. Let me tell you that if you&#8217;ve had this problem, you will probably remember the error number: 5172. We will see together how to fix this type of error manually. And I must say that is not too easy. Often, for a manual recovery, it is necessary to know the internal structures of the mdf <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/posts\/206"}],"collection":[{"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/comments?post=206"}],"version-history":[{"count":3,"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/posts\/206\/revisions"}],"predecessor-version":[{"id":224,"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/posts\/206\/revisions\/224"}],"wp:attachment":[{"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/media?parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/categories?post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stellarsqldatabaserecovery.com\/blog\/wp-json\/wp\/v2\/tags?post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}