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

Troubleshooting Guide: SQL Server Error 13038 (SET Option Issue)

Why This Error Happens

Error 13038 typically occurs when a required SET option is misconfigured or incompatible with the current session context, often related to indexed views, computed columns, or filtered indexes that demand strict session-level settings. This frequently stems from the QUOTED_IDENTIFIER or ANSI_NULLS options being set to OFF when the schema-bound object requires them to be ON. Corrupted connection strings or outdated client drivers on Windows Server 2025/Windows 11 can also fail to pass the correct SET options during the handshake.

Step-by-Step Resolution Guide

Step 1: Verify Current Session SET Options

  • Open SQL Server Management Studio (SSMS) and connect to the target instance.
  • Run the following query to check current session configurations: DBCC USEROPTIONS;
  • Confirm whether quoted_identifier and ansi_nulls are listed as SET.

Step 2: Correct the Database and Connection Defaults

  • Navigate to Tools > Options > Query Execution > SQL Server > Advanced in SSMS.
  • Ensure SET QUOTED_IDENTIFIER and SET ANSI_NULLS are checked to True.
  • For programmatic connections (ODBC/OLEDB), verify the connection string includes QuotedId=Yes;AnsiNPW=Yes;.

Step 3: Rebuild the Affected Schema-Bound Object

  • If the error persists on a specific View or Index, drop and recreate the object.
  • Execute explicit commands before creation:
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
CREATE VIEW dbo.YourView AS ...

Step 4: Update Client Drivers and Check Windows Compatibility

  • Navigate to C:\Windows\System32\msodbcsql18.msi path (or Microsoft Download Center) to ensure the ODBC Driver 18 is installed.
  • Restart the “SQL Server” service via services.msc to clear cached execution plans that may hold the old SET context.

Alternative or Verification Steps

  • Verification: Re-run the original query or application process; the error should clear immediately once DBCC USEROPTIONS shows the correct ON status for both flags.
  • Alternative: If the error originates from a legacy application that cannot be modified, create a Logon Trigger to force the correct SET options at the server level for every incoming session.