Troubleshooting Guide: Error 5036 – “MODIFY FILE Failed. Specify Logical Name.”
Why This Error Happens
This error occurs when an ALTER DATABASE ... MODIFY FILE statement references a logical file name that does not exist in the target database, usually due to a typo or mismatch with the actual name stored in system catalogs. It can also happen if the database schema was recently restored, renamed, or migrated from another instance, causing the logical names in sys.master_files to differ from what the administrator expects. In some cases, case sensitivity on a case-sensitive collation instance causes an otherwise “correct-looking” name to fail validation.
Step-by-Step Resolution Guide
Step 1: Verify the Correct Logical File Name
- Open SQL Server Management Studio (SSMS) or Azure Data Studio connected to your SQL Server 2025 instance.
- Run the following query to list actual logical names for the target database:
SELECT name AS LogicalName, physical_name, type_desc
FROM sys.master_files
WHERE database_id = DB_ID('YourDatabaseName');
- Compare the
LogicalNamecolumn output against the name used in yourMODIFY FILEcommand.
Step 2: Correct the ALTER DATABASE Statement
- Update your T-SQL script to reference the exact logical name (case-sensitive if the instance uses a binary or case-sensitive collation).
- Example corrected syntax:
ALTER DATABASE YourDatabaseName
MODIFY FILE (NAME = 'YourDatabaseName_Data', SIZE = 500MB);
- Ensure there are no trailing spaces or hidden characters copied from documentation or scripts.
Step 3: Check for Recent Restore or Attach Operations
- If the database was recently restored or attached on Windows Server 2025, logical names may differ from the original source server.
- Run
sp_helpfilewhile connected to the specific database to cross-reference names:
USE YourDatabaseName;
EXEC sp_helpfile;
- Update any deployment or maintenance scripts to reflect the current logical names post-migration.
Step 4: Validate Permissions and Script Execution Context
- Confirm the executing account has
ALTERpermission on the database (db_owner or sysadmin role). - Re-run the script as a user with elevated privileges if a permissions-related silent failure is suspected alongside the naming issue.
Alternative or Verification Steps
- After correcting the logical name, re-run the
ALTER DATABASE MODIFY FILEcommand and confirm it completes without error; then verify the change usingsys.master_filesagain to confirm size/path updates were applied. - If the issue persists, generate a fresh scripting of the database file structure via SSMS (Right-click Database → Tasks → Generate Scripts) to ensure your reference script matches the live, current schema exactly.