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

Troubleshooting Guide: SQL Server Error 5038 – “MODIFY FILE failed”

Why This Error Happens

Error 5038 occurs when an ALTER DATABASE ... MODIFY FILE statement is executed without specifying at least one modifiable property (such as SIZE, FILEGROWTH, MAXSIZE, or NEWNAME) in the command. This is typically caused by a syntax omission where the FILENAME property alone is provided, or where the file properties clause is empty or malformed. In SQL Server 2025, this validation check has become stricter, causing scripts that previously ran on older versions (via legacy automation or deployment tools) to now fail during execution.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Statement

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and review the exact query that triggered Error 5038.
  • Check SQL Server Error Logs located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the full query context.
  • Look specifically for ALTER DATABASE [YourDB] MODIFY FILE (NAME = 'logical_name') statements missing additional parameters.

Step 2: Correct the T-SQL Syntax

  • Rewrite the statement to include at least one valid property inside the parentheses.
  • Example of broken syntax: ALTER DATABASE MyDB MODIFY FILE (NAME = N'MyDB_log');
  • Example of corrected syntax: ALTER DATABASE MyDB MODIFY FILE (NAME = N'MyDB_log', SIZE = 51200KB);
  • Ensure you specify a valid property such as SIZE, MAXSIZE, FILEGROWTH, or NEWNAME depending on the intended administrative action.

Step 3: Validate File Metadata Before Re-running

  • Run SELECT name, physical_name, size, growth FROM sys.master_files WHERE database_id = DB_ID('MyDB'); to confirm the current state of the file.
  • Cross-reference the logical file name to ensure it matches exactly (case-sensitivity and trailing spaces can cause mismatches).
  • Re-execute the corrected ALTER DATABASE command in a test/staging environment first if this is a production server.

Step 4: Update Automation Scripts or Deployment Tools

  • If the error originates from a third-party backup tool, ORM migration script, or PowerShell deployment module, check for a version update.
  • Navigate to the tool’s configuration directory (e.g., C:\Scripts\DBDeploy\) and inspect any .sql template files for incomplete MODIFY FILE blocks.
  • Patch the template to include a static or dynamically calculated property value before re-deploying.

Alternative or Verification Steps

  • Verify the fix by querying sys.database_files immediately after running the corrected command to confirm the size or growth values were updated as expected.
  • If the error persists despite correct syntax, restart the SQL Server service via services.msc or run sqlcmd -S localhost -Q "SELECT @@VERSION" to rule out a stale metadata cache issue following a recent SQL Server 2025 cumulative update.