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

Troubleshooting Guide: SQL Server Audit Error 13004

Why This Error Happens

Error 13004 occurs when SQL Server Audit encounters an issue with the specified audit name, typically because the audit object does not exist, has been dropped, or was never created with that exact name in the current database context. This can also happen if there is a case-sensitivity mismatch, a typo in the audit name reference, or if the audit exists in a different scope (server-level vs. database-level) than where it is being queried. Additionally, corrupted system metadata in sys.server_audits or insufficient permissions to view audit definitions can trigger this error.

Step-by-Step Resolution Guide

Step 1: Verify the Audit Name Exists

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run the following query to list all existing audits:
  SELECT name, audit_id, status_desc, type_desc 
  FROM sys.server_audits;
  • Compare the exact spelling, casing, and spacing of the audit name against what you referenced in your script or application.

Step 2: Check Permissions on the Audit Object

  • Ensure the login being used has ALTER ANY SERVER AUDIT or CONTROL SERVER permission.
  • Run this command to grant the necessary permission if missing:
  GRANT ALTER ANY SERVER AUDIT TO [YourLoginName];
  • Verify the login is not mapped incorrectly due to recent Active Directory changes on Windows Server 2025.

Step 3: Recreate the Audit if Metadata is Corrupted

  • If the audit name appears in sys.server_audits but still throws Error 13004, drop and recreate it.
  • First, disable the audit:
  ALTER SERVER AUDIT [YourAuditName] WITH (STATE = OFF);
  • Drop and recreate the audit specification:
  DROP SERVER AUDIT [YourAuditName];
  CREATE SERVER AUDIT [YourAuditName]
  TO FILE (FILEPATH = 'C:\SQLAudits\');

Step 4: Restart the SQL Server Service

  • Navigate to Services.msc on Windows Server 2025 / Windows 11.
  • Locate SQL Server (MSSQLSERVER) or your named instance.
  • Right-click and select Restart to clear any cached metadata locks related to the audit object.

Alternative or Verification Steps

  • Run SELECT * FROM sys.dm_server_audit_status; to confirm the audit is now listed as ON and functioning without errors.
  • If the issue persists, check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for additional context on why the audit name resolution is failing.