Skip to main content

Free demo previews every object and exports 25 records per table.

PCVITA Logo
SQL Server

How to Fix Page Level Corruption in SQL Server?

  • Mohit JhaPublished ByMohit Jha
  • Tej Pratap ShuklaApproved ByTej Pratap Shukla
  • Published
  • Updated
  • Reading Time6 min
Quick Answer

Page level corruption in SQL Server damages single 8 KB pages inside your database files. You get 3 methods in this guide. Method 1 restores the damaged pages from backup. Method 2 repairs the database with DBCC CHECKDB. Method 3 recovers the data with PCVITA software. Copy your database files before any repair.

Your query fails with a checksum error and SQL Server names a page number. Damage to one page already blocks the table that stores its rows.

This guide shows how to fix page level corruption in SQL Server with 3 methods. Steps follow the Microsoft Learn pages on page restore and DBCC CHECKDB.

What Causes Page Level Corruption in SQL Server?

SQL Server stores data in 8 KB pages. Writes that fail halfway or bad disk sectors leave one page unreadable while the rest of the database works.

  • Disk faults. Bad sectors or a failing controller damage pages on write.
  • Power loss. Sudden shutdown leaves a torn page behind.
  • Virus attacks. Malware changes database files outside SQL Server.
  • Faulty updates. Wrong drivers or patches write bad data to the disk.
Do You Know?

Microsoft states that checksum and torn write errors report the page ID directly. SQL Server also records damaged pages in the suspect_pages table of msdb.

How Do You Find the Damaged Pages?

Collect the page IDs first. Every method below starts from that list.

  1. Copy the MDF, NDF and LDF files to another disk.
  2. Open a New Query window in SQL Server Management Studio.
  3. Execute the statements below.
DBCC CHECKDB (SalesDB) WITH NO_INFOMSGS;
SELECT * FROM msdb.dbo.suspect_pages;
  1. Note the file ID and the page ID of every damaged page. You write them as 1:57.

Your first statement reports errors without a repair. Microsoft asks you to execute it first because the output shows which repair level you need.

Method #1: Restore Damaged Pages From Backup (Free, Needs Backups)

Page restore repairs a handful of pages without a full restore. Your database needs the full or bulk logged recovery model and Microsoft recommends the full model.

  1. Restore the damaged pages from a full backup. Use the PAGE clause and the IDs from the list.
RESTORE DATABASE SalesDB PAGE='1:57, 1:202'
FROM DISK = 'D:\Backup\SalesDB_full.bak'
WITH NORECOVERY;
  1. Apply the latest differential backup and every log backup after it with RESTORE LOG and WITH NORECOVERY.
  2. Take a tail log backup with BACKUP LOG.
  3. Restore the tail log backup WITH RECOVERY and open the pages again.
Heads Up

Page restore skips the transaction log and the GAM, SGAM and PFS allocation pages. It skips page 0 of every data file and page 1:9 too. Online page restore needs Enterprise edition. Use Method 2 or Method 3 in these cases.

Method #2: Repair With DBCC CHECKDB (Free, Data Loss Risk)

DBCC CHECKDB repairs the database in place. Any repair option needs single user mode. Microsoft asks for physical copies of every database file before a repair.

  1. Copy the MDF, NDF and LDF files to another disk.
  2. Set the database to single user mode and start with the repair that loses no data.
ALTER DATABASE SalesDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DBCC CHECKDB (SalesDB, REPAIR_REBUILD);
  1. Execute DBCC CHECKDB (SalesDB) again. Use the next option only when errors remain.
DBCC CHECKDB (SalesDB, REPAIR_ALLOW_DATA_LOSS);
  1. Execute DBCC CHECKCONSTRAINTS, set the database back to MULTI_USER and take a full backup.
  • REPAIR_REBUILD. Repairs without data loss. Examples are a missing row in a nonclustered index or a rebuilt index.
  • REPAIR_ALLOW_DATA_LOSS. Tries to repair every error. SQL Server can deallocate rows and pages and does not keep foreign key constraints during the repair.
  • REPAIR_FAST. Does nothing. Microsoft keeps it for backward compatibility.
Heads Up

Deallocated data does not come back. Microsoft states that REPAIR_ALLOW_DATA_LOSS can lose more data than a restore from the last known good backup.

Method #3: Recover the Data With PCVITA Software (Paid Export)

Use this method when you hold no backup and cannot accept the data loss of a repair. PCVITA SQL Database Recovery Tool reads the damaged MDF file with its NDF files and shows every table and record before the export.

  • No SQL Server needed. The software scans files on any Windows machine.
  • Two scan modes. Quick Scan handles normal damage and Advance Scan handles severe damage.
  • Keys retained. Primary keys, foreign keys and indexes come back with their tables.
  • Outputs. Export to a live SQL Server database, a SQL script or CSV files.
PCVITA SQL Database Recovery ToolRepair MDF and NDF files and export the data.
Version 14.0 for Windows. 30 day money back guarantee.
  1. Install PCVITA SQL Database Recovery Tool and click Open. Select the damaged MDF file.

Open dialog with the corrupt MDF file selected

  1. Select Quick Scan or Advance Scan.

Advance Scan option with the Recover Deleted Objects checkbox

  1. Preview tables, views and procedures in the object tree.

Preview screen with the object tree and table records

  1. Click Export and select SQL Server Database. Create a new database or select an existing one.

Export screen with the Create New Database and Export to Existing Database options

Pro Tip

The free demo exports 25 records per table. Compare one table with your source before you buy the full edition.

Which Method Fits Your Case?

MethodWorks WhenRisk to DataCost
#1 Page RestoreYou hold full and log backupsNoneFree
#2 DBCC CHECKDB RepairNo backup existsRows and pages can be lostFree
#3 PCVITA SoftwareBackup and repair failNone to the original fileFree demo, $249 full

Safe Handling Tips

  • Copy first. Save every database file before a repair.
  • Start with backups. A restore from backup beats every repair.

FAQs About Page Level Corruption

How do I find page level corruption in SQL Server?

Execute DBCC CHECKDB without a repair option and read the page IDs in its output. Query the suspect_pages table in msdb for pages that SQL Server already flagged.

Can I restore a single page in SQL Server?

Yes. Microsoft supports page restore for databases in the full or bulk logged recovery model. Online page restore needs Enterprise edition and offline page restore works in all editions.

Which pages can SQL Server not restore?

Microsoft lists the transaction log and the allocation pages GAM, SGAM and PFS. Page 0 of every data file and page 1:9 also stay out of a page restore.

Is REPAIR_ALLOW_DATA_LOSS safe?

No. The option can deallocate rows and pages and Microsoft calls it an emergency last resort. Restore from the last known good backup whenever you have one.

Does REPAIR_FAST fix my database?

No. Microsoft keeps REPAIR_FAST only for backward compatibility and it performs no repair actions.

Does PCVITA SQL Database Recovery Tool need SQL Server to scan files?

No. The software scans MDF and NDF files on any Windows machine and exports the recovered data to a live SQL Server database, a SQL script or CSV files.

Does the free demo of PCVITA SQL Database Recovery Tool export data?

Yes. The free demo previews every object and exports 25 records per table. The full edition costs $249 for one licence.

Closing Words

Page level corruption damages single pages but blocks the tables that use them. List the damaged pages first and restore them from backup when you hold one. Repair with DBCC CHECKDB only after you copy your files.

  • Methods 1 and 2 use Microsoft commands and cost nothing.
  • Method 3 recovers the data without a backup and without data loss in your original file.