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

Troubleshooting Guide: SQL Server Error 3697 – Batch Waits Statistics

Why This Error Happens

Error 3697 is typically an informational/diagnostic message raised internally by the SQL Server Query Processor when it logs batch-level wait statistics (%ls is a placeholder for the specific wait type and duration data). This usually surfaces when a query batch encounters significant resource contention—such as CXPACKET, PAGEIOLATCH, or RESOURCE_SEMAPHORE waits—and the Extended Events or trace flag diagnostics are configured to capture batch-level wait telemetry. In Microsoft SQL Server 2025, this can also occur if the Query Store diagnostic capture mode or a related Extended Events session is misconfigured, causing the message to be logged excessively or interpreted as an error rather than a diagnostic trace.

Step-by-Step Resolution Guide

Step 1: Identify the Triggering Extended Events Session

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run the following query to check active sessions capturing wait stats:
  SELECT * FROM sys.dm_xe_sessions WHERE name LIKE '%wait%';
  • Confirm whether sql_batch_completed or wait_info events are bound to a custom session logging to the error log.

Step 2: Review and Adjust Trace Flags

  • Check if Trace Flag 3697 or related diagnostic flags (e.g., 8666, 3604) are enabled at startup.
  • Run:
  DBCC TRACESTATUS(-1);
  • If found active unintentionally, disable it:
  DBCC TRACEOFF (3697, -1);
  • Remove the flag from SQL Server startup parameters via SQL Server Configuration Manager (Start → SQL Server 2025 Configuration Manager → SQL Server Services → Properties → Startup Parameters).

Step 3: Update SQL Server 2025 Cumulative Update

  • Navigate to Microsoft Update Catalog and confirm the instance is on the latest Cumulative Update (CU) for SQL Server 2025, as early builds have known false-positive logging bugs for Error 3697.
  • Apply the update and restart the SQL Server service via:
  Restart-Service -Name 'MSSQLSERVER' -Force

Step 4: Validate Resource Governor and Query Store Settings

  • Open Object Explorer → Databases → [YourDB] → Query Store → Properties.
  • Ensure “Capture Mode” is not set to ALL in high-transaction environments, as this increases batch-wait logging overhead.
  • Set to AUTO to reduce unnecessary diagnostic writes:
  ALTER DATABASE [YourDB] SET QUERY_STORE (OPERATION_MODE = READ_WRITE, QUERY_CAPTURE_MODE = AUTO);

Step 5: Check Windows Server Event Viewer for Correlated I/O Errors

  • Open Event Viewer (eventvwr.msc) on Windows Server 2025 / Windows 11.
  • Navigate to Windows Logs → Application and filter by Source: MSSQLSERVER.
  • Cross-reference timestamps with disk or storage subsystem warnings (Event ID 153 or 129), as underlying I/O latency often triggers the batch wait logging.

Alternative or Verification Steps

  • Verify the fix: Re-run representative workloads and monitor sys.dm_exec_query_stats and the SQL Server Error Log for recurrence of message 3697; absence of the log entry over a 24-hour monitoring window confirms resolution.
  • Alternative: If the error persists, isolate the issue by running sp_configure 'show advanced options', 1 and temporarily disabling verbose diagnostic logging to confirm if the message is purely cosmetic rather than indicative of actual performance degradation.