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

Troubleshooting Guide: SQL Server Error 5526 — FILESTREAM Log File Removal Conflict

Why This Error Happens

This error occurs when an attempt is made to remove a FILESTREAM log file while an active FILESTREAM data filegroup still references it. SQL Server 2025 maintains a dependency link between the FILESTREAM transaction log metadata and its associated data filegroup to ensure transactional consistency for BLOB data stored outside the primary database files. Until the filegroup itself is dropped or the dependent files are reassigned, the storage engine blocks removal of the log file to prevent orphaned references and potential data corruption.

Step-by-Step Resolution Guide

Step 1: Identify the Dependent Filegroup

  • Run the following query to list FILESTREAM filegroups and their associated files:
  SELECT fg.name AS FilegroupName, f.name AS FileName, f.physical_name
  FROM sys.filegroups fg
  JOIN sys.database_files f ON fg.data_space_id = f.data_space_id
  WHERE fg.type = 'FD';
  • Note the exact filegroup name tied to the FILESTREAM log file mentioned in the error message.

Step 2: Remove Data Files from the Filegroup First

  • Before dropping the log file, remove any data files still assigned to the FILESTREAM filegroup:
  ALTER DATABASE [YourDatabase]
  REMOVE FILE [FILESTREAM_DataFile_Name];
  • Confirm no active FILESTREAM data remains referenced in sys.database_files.

Step 3: Drop the FILESTREAM Filegroup

  • Once all data files are removed, drop the filegroup itself:
  ALTER DATABASE [YourDatabase]
  REMOVE FILEGROUP [FILESTREAM_Filegroup_Name];
  • This severs the dependency link that was blocking log file removal.

Step 4: Remove the FILESTREAM Log File

  • Now attempt to remove the log file safely:
  ALTER DATABASE [YourDatabase]
  REMOVE FILE [FILESTREAM_LogFile_Name];
  • Verify Windows Server 2025 file permissions on the FILESTREAM directory (typically under C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\FILESTREAM\) are not locking the file via antivirus or backup agents.

Step 5: Restart SQL Server Service (If Needed)

  • If the file remains locked, restart the SQL Server service via Services.msc or PowerShell:
  Restart-Service -Name 'MSSQLSERVER' -Force
  • This clears any cached file handles tied to the old FILESTREAM configuration.

Alternative or Verification Steps

  • Verify success by re-running the sys.database_files query — the FILESTREAM log file and filegroup should no longer appear.
  • If removal still fails, check Event Viewer (Windows Logs → Application) for Event ID 5526 recurrence, and ensure no open transactions or replication/Change Data Capture jobs are still referencing the FILESTREAM filegroup.