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

Troubleshooting Guide: SQL Server Error 5069 – ALTER DATABASE Statement Failed

Why This Error Happens

Error 5069 is a generic “wrapper” error raised by SQL Server 2025 when an underlying statement within the ALTER DATABASE command fails to execute. The actual root cause is almost always reported in a preceding error message (such as insufficient permissions, a file already in use, an invalid file path, or a database currently in a state that prevents modification). On Windows Server 2025 / Windows 11, this is frequently triggered by locked database files, a database stuck in SINGLE_USER mode, or the SQL Server service account lacking NTFS permissions on the target directory.

Step-by-Step Resolution Guide

Step 1: Identify the Preceding Error Message

  • Open SQL Server Management Studio (SSMS) and re-run the ALTER DATABASE command.
  • Check the Messages tab for the error immediately above 5069 (e.g., Error 5070, 5172, or 1105) — this identifies the true root cause.
  • Review the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for additional context.

Step 2: Verify Database State and Active Connections

  • Run the following query to check if the database is locked in a restrictive state:
  SELECT name, state_desc, user_access_desc 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • If the database is stuck in SINGLE_USER or RESTRICTED_USER mode, kill blocking sessions using KILL <session_id>.
  • Set the database back to multi-user mode if needed:
  ALTER DATABASE YourDatabaseName SET MULTI_USER;

Step 3: Check File Permissions and Service Account Rights

  • Navigate to the data/log file directory, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.
  • Right-click the .mdf or .ldf file, go to Properties > Security, and confirm the SQL Server service account (e.g., NT Service\MSSQLSERVER) has Full Control.
  • If permissions are missing, click Edit > Add, enter the service account name, and grant Full Control, then click Apply.

Step 4: Restart the SQL Server Service to Release File Locks

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Locate SQL Server (MSSQLSERVER), right-click, and select Restart.
  • This releases any orphaned file handles caused by crashed sessions or external backup tools (e.g., antivirus scanning the .mdf file).

Alternative or Verification Steps

  • Verify the fix by re-running the original ALTER DATABASE statement; a successful execution returns “Command(s) completed successfully” with no preceding error codes.
  • If the issue persists, run DBCC CHECKDB('YourDatabaseName') to rule out file corruption as the underlying cause of the failed alteration.