How to fix Error 5205 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 5205 — “Moving page %d:%d failed”

Why This Error Happens

Error 5205 occurs when SQL Server’s DBCC SHRINKFILE or auto-shrink operation attempts to relocate allocated pages from the end of a data file but encounters a page it cannot move, typically due to page corruption, an active transaction holding a lock on that page, or an unmovable allocation unit (such as a forwarded row in a heap, LOB data, or a page belonging to a system object). This is also commonly triggered by insufficient free space in the target location within the file or by index fragmentation that prevents the shrink engine from relocating extent pages cleanly. In some cases, underlying disk I/O errors or a corrupted database page map (GAM/SGAM/PFS pages) cause the page-move operation to fail outright.

Step-by-Step Resolution Guide

Step 1: Check Database Integrity First

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to rule out corruption.
  • Review the SQL Server error log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for accompanying 823, 824, or 825 errors indicating disk-level corruption.
  • If corruption is found, restore from a known-good backup rather than proceeding with shrink operations.

Step 2: Identify and Resolve Blocking Transactions

  • Run sp_whoisactive or query sys.dm_tran_locks to check for long-running transactions holding locks on the file being shrunk.
  • Kill or wait out blocking sessions using KILL <session_id>; only after confirming it is safe to terminate.
  • Avoid running shrink operations during peak transaction periods or active ETL jobs.

Step 3: Rebuild Indexes and Heaps Before Shrinking

  • Run ALTER INDEX ALL ON YourTableName REBUILD WITH (ONLINE = ON); (Enterprise/Online capable editions) to eliminate forwarded records and fragmented heap pages.
  • For heaps specifically, forwarded pointers are a known cause of page-move failures — rebuild the heap using ALTER TABLE YourTableName REBUILD;.
  • Re-attempt the shrink operation with DBCC SHRINKFILE (N'YourLogicalFileName', TRUNCATEONLY); first to avoid unnecessary page movement.

Step 4: Retry Shrink in Smaller Increments

  • Instead of a single large shrink, run DBCC SHRINKFILE (N'YourLogicalFileName', <target_size_in_MB>) in smaller incremental steps.
  • Monitor tempdb and transaction log space usage during the operation, since insufficient space can also trigger page-move failures.
  • If using Windows Server 2025 storage tiers (ReFS or Storage Spaces Direct), confirm the volume isn’t throttling I/O during the operation via Performance Monitor (PhysicalDisk counters).

Step 5: Update SQL Server and Verify File System Health

  • Apply the latest Cumulative Update for SQL Server 2025 from Microsoft Update Catalog, as page-move logic in shrink operations has known fixes in recent builds.
  • Run chkdsk C: /f /r (or the relevant drive hosting your .mdf/.ndf files) on Windows Server 2025 to rule out NTFS/ReFS file system corruption.
  • Confirm the SQL Server service account has full read/write permissions on the data file directory via File Properties > Security > Advanced.

Alternative or Verification Steps

  • After applying fixes, re-run DBCC SHRINKFILE during an off-peak maintenance window and confirm no Error 5205 appears in the error log or sys.messages output.
  • If the issue persists, use DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS only as a last resort in a non-production environment, and consider migrating the affected table’s data to a new file group instead of shrinking in place.