Troubleshooting Guide: SQL Server Error 3174 – “The file ‘%ls’ cannot be moved by this RESTORE operation”
Why This Error Happens
This error occurs when SQL Server 2025 attempts to restore a database but cannot relocate one or more data/log files because the target path specified does not exist, is inaccessible, or lacks proper permissions for the SQL Server service account. It commonly happens when restoring a backup to a new server with a different folder structure, or when the destination drive letter referenced in the backup header is missing on the target Windows Server 2025/Windows 11 machine. Additionally, this can occur if the RESTORE command uses a MOVE clause pointing to a path that is locked, read-only, or still in use by another process.
Step-by-Step Resolution Guide
Step 1: Verify the Original File Paths in the Backup
- Run
RESTORE FILELISTONLY FROM DISK = 'C:\Backups\YourBackup.bak'to list the logical and physical file names stored in the backup header. - Note the
LogicalNameandPhysicalNamecolumns, as these are required for theMOVEclause.
Step 2: Confirm the Target Directory Exists and Is Accessible
- Check that the destination folder (e.g.,
D:\SQLData\orE:\SQLLogs\) actually exists on the Windows Server 2025 host. - Create the folder manually if missing using File Explorer or
mkdir D:\SQLData. - Ensure the drive is not mapped to a network share that may be disconnected or slow to respond.
Step 3: Grant Proper NTFS Permissions to the SQL Server Service Account
- Right-click the target folder (e.g.,
D:\SQLData), go to Properties > Security, and verify the SQL Server service account (e.g.,NT Service\MSSQLSERVER) has Full Control. - Use PowerShell to apply permissions quickly:
icacls "D:\SQLData" /grant "NT SERVICE\MSSQLSERVER:(OI)(CI)F"
- Restart the SQL Server service if permissions were just applied.
Step 4: Rerun the RESTORE Command with Explicit MOVE Clauses
- Use the following syntax to explicitly redirect each file:
RESTORE DATABASE YourDB
FROM DISK = 'C:\Backups\YourBackup.bak'
WITH MOVE 'YourDB_Data' TO 'D:\SQLData\YourDB.mdf',
MOVE 'YourDB_Log' TO 'E:\SQLLogs\YourDB_log.ldf',
REPLACE;
- Double-check that no typos exist in the logical file names captured in Step 1.
Step 5: Check for File Locks or Conflicting Processes
- Ensure no other SQL Server instance, antivirus scanner, or backup agent is locking the target
.mdf/.ldffiles. - Use
Resource Monitor(Windows 11) orHandle.exe(Sysinternals) to identify and release any locks on the destination path.
Alternative or Verification Steps
- After the restore completes, run
SELECT name, physical_name FROM sys.master_files WHERE database_id = DB_ID('YourDB');to confirm the files now point to the correct new paths. - If the error persists, try restoring to a completely different local drive (e.g.,
C:\Temp\SQLRestore\) to rule out permission inheritance issues on the original target volume.