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

Troubleshooting Guide: SQL Server Error 1842 – File Size Specification Error

Why This Error Happens

Error 1842 occurs when SQL Server 2025 encounters a file size specification that does not meet the minimum required threshold or conflicts with the existing file’s current size during a resize, restore, or database creation operation. This typically happens when a MODIFY FILE or ALTER DATABASE command specifies a size smaller than the current allocated size of the data or log file. Additionally, this can be triggered by insufficient disk space on the target volume, incorrect unit specifications (MB vs GB), or a mismatch between the file growth settings and the physical file structure on disk.

Step-by-Step Resolution Guide

Step 1: Verify Current File Size and Specifications

  • Open SQL Server Management Studio (SSMS) and connect to the instance running SQL Server 2025.
  • Run the following query to check current file sizes: SELECT name, size, size*8/1024 AS SizeMB FROM sys.database_files;
  • Compare this output against the size value specified in your ALTER DATABASE or CREATE DATABASE command to ensure the new size is equal to or greater than the current size.

Step 2: Correct the Database File Modification Command

  • Navigate to the specific database using USE [YourDatabaseName];
  • Re-run the modification with a corrected, larger size value, for example: ALTER DATABASE [YourDatabaseName] MODIFY FILE (NAME = N'YourDataFile', SIZE = 51200MB);
  • Ensure that the SIZE parameter uses the correct unit (KB, MB, GB) and does not contain truncated decimal points that round down below the minimum file size.

Step 3: Check Physical Disk Space and Permissions

  • Open File Explorer or PowerShell on Windows Server 2025 and navigate to the default data directory, typically located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA.
  • Verify that the volume has sufficient free space to accommodate the requested file size increase.
  • Confirm that the NT SERVICE\MSSQLSERVER service account has “Full Control” permissions on the DATA folder via the Security tab in Folder Properties.

Step 4: Restart the SQL Server Service

  • Open the Services application (services.msc) on Windows Server 2025 or Windows 11.
  • Locate “SQL Server (MSSQLSERVER)” or the specific named instance, right-click, and select “Restart” to clear any cached file allocation locks.
  • Attempt the file size modification query again via SSMS to confirm the error has cleared.

Alternative or Verification Steps

  • Verification: Run DBCC SQLPERF(LOGSPACE); to confirm the log file growth was applied successfully without triggering the 1842 error again.
  • Alternative: If the error persists due to disk constraints, use ALTER DATABASE [YourDatabaseName] MODIFY FILE (NAME = N'YourDataFile', FILEGROWTH = 10%); to switch to percentage-based growth instead of a fixed size to bypass static sizing conflicts.