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

Troubleshooting Guide: Error 5244 – Repair Statement Not Processed (Read-Only Files)

Why This Error Happens

This error occurs when SQL Server’s DBCC CHECKDB repair process attempts to write corrective changes to database files that are flagged as read-only at either the file system or database level. This is common after restoring a database from a read-only backup source, working with files on read-only media, or when NTFS file permissions were altered. Since repair operations (REPAIRREBUILD or REPAIRALLOWDATALOSS) require write access to modify corrupted pages, SQL Server blocks the operation entirely to prevent an inconsistent repair state.

Step-by-Step Resolution Guide

Step 1: Verify the Database READ_ONLY Status

  • Open SQL Server Management Studio (SSMS) or a query window connected to the instance.
  • Run the following command to check the current state:
  SELECT name, is_read_only FROM sys.databases WHERE name = 'YourDatabaseName';
  • If is_read_only returns 1, proceed to Step 2 to change it.

Step 2: Set the Database to READ_WRITE Mode

  • Execute the following T-SQL command, ensuring no other active connections are using the database:
  ALTER DATABASE YourDatabaseName SET READ_WRITE WITH ROLLBACK IMMEDIATE;
  • The WITH ROLLBACK IMMEDIATE clause forcibly disconnects other users to apply the change instantly.

Step 3: Check NTFS File Permissions on the Physical Files

  • Navigate to the default data directory, typically located at:
    C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\
  • Right-click the .mdf and .ldf files, select Properties > Security.
  • Ensure the NT SERVICE\MSSQLSERVER account (or your specific named instance service account) has Full Control permissions.
  • Also verify the Read-only checkbox under the General tab is unchecked for these files.

Step 4: Confirm Disk and Volume Status

  • Open Disk Management (diskmgmt.msc) on Windows Server 2025 or Windows 11.
  • Verify the volume hosting the database files is not mounted in a read-only state (common with SAN snapshots or certain cloud-attached disks).
  • If using Storage Spaces or a SAN LUN, confirm the volume attribute using DiskPart:
  diskpart
  list volume
  select volume X
  attributes volume
  • If “Read-only” appears in the attributes, clear it using attributes volume clear readonly.

Step 5: Re-run the Repair Statement

  • Once permissions and database mode are corrected, re-initiate the repair process:
  DBCC CHECKDB (YourDatabaseName, REPAIR_ALLOW_DATA_LOSS);
  • Monitor the SQL Server Error Log to confirm the process completes without triggering Error 5244 again.

Alternative or Verification Steps

  • Verification: After running the repair, execute DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS, ALL_ERRORMSGS; again to confirm consistency errors are resolved and the file write status remains stable.
  • Alternative: If the files remain locked due to a third-party backup agent or antivirus software holding a handle on the .mdf/.ldf files, temporarily pause the agent/AV real-time scanning and retry the ALTER DATABASE command in Step 2.