Troubleshooting Guide: SQL Server Error 1934 — Incorrect SET Options
Why This Error Happens
This error occurs because SQL Server 2025 requires specific session-level SET options to be configured correctly before it can create or operate on indexed views, indexes on computed columns, or perform operations involving filtered indexes. When connections are made through drivers, ORMs, or legacy applications that don’t explicitly configure these options, the session inherits incorrect defaults (often ANSI_NULLS or QUOTED_IDENTIFIER set to OFF). SQL Server rejects the operation because mismatched SET options can lead to non-deterministic results or data corruption in these specialized index structures.
Step-by-Step Resolution Guide
Step 1: Identify the Offending SET Options
- The error message itself specifies which options are misconfigured (e.g.,
ANSI_NULLS,ANSI_PADDING,ANSI_WARNINGS,CONCAT_NULL_YIELDS_NULL,QUOTED_IDENTIFIER, orNUMERIC_ROUNDABORT). - Run the following query to check current session defaults for the affected login or database:
DBCC USEROPTIONS;- Cross-reference this output against the required values listed in Microsoft’s documentation for indexed views and computed columns.
Step 2: Correct the SET Options at the Session Level
- Add explicit
SETstatements at the top of your stored procedure, script, or application connection string. - For most indexed view/computed column scenarios, ensure the following block precedes your DDL or DML statement:
SET ANSI_NULLS ON;SET ANSI_PADDING ON;SET ANSI_WARNINGS ON;SET ARITHABORT ON;SET CONCAT_NULL_YIELDS_NULL ON;SET QUOTED_IDENTIFIER ON;SET NUMERIC_ROUNDABORT OFF;- Save and re-execute the script in SQL Server Management Studio (SSMS) 21 or your application context.
Step 3: Fix the Database-Level Default (If Using Legacy Compatibility)
- Open SSMS, navigate to Databases > [Your Database] > Properties > Options.
- Check the Compatibility Level field; ensure it is not forcing legacy ANSI behavior inconsistent with SQL Server 2025 engine requirements.
- Verify
QUOTED_IDENTIFIERis enabled at the database level by running: ALTER DATABASE [YourDatabaseName] SET QUOTED_IDENTIFIER ON;- Restart the application connection pool to ensure new sessions pick up the corrected defaults.
Step 4: Audit Application and Driver Connection Strings
- If using ODBC, JDBC, or OLE DB drivers on Windows Server 2025 or Windows 11, verify the driver version supports SQL Server 2025 TDS protocol updates.
- Check connection string parameters (e.g.,
QuotedId=yesfor ODBC) to ensure the driver isn’t silently overriding session settings on connect. - Update the driver via the Microsoft ODBC Driver 18+ for SQL Server installer if an outdated version is detected.
Alternative or Verification Steps
- To verify the fix, re-run the original CREATE INDEX or indexed view query; if successful, query
sys.indexesto confirm the object was created without errors. - If the error persists despite correct SET options, drop and recreate the indexed view entirely, as a corrupted metadata definition from a previous failed creation attempt may be causing residual conflicts.