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

Troubleshooting Guide: SQL Server Error 1073 — Invalid Cursor Option

Why This Error Happens

This error occurs when a T-SQL statement references a cursor option (such as FORWARD_ONLY, SCROLL, STATIC, KEYSET, or DYNAMIC) that is either misspelled, deprecated, or incompatible with the cursor type being declared. It frequently arises after migrating legacy scripts to SQL Server 2025, where certain older cursor syntax combinations are no longer parsed the same way. Additionally, corrupted or outdated client drivers (ODBC/OLE DB) on Windows Server 2025 or Windows 11 can send malformed cursor declaration requests that the Database Engine rejects.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Statement

  • Capture the exact query text using SQL Server Profiler or Extended Events (sp_server_diagnostics can help isolate the session).
  • Check the error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the full statement context tied to Error 1073.
  • Look specifically for the DECLARE CURSOR syntax used in the failing batch.

Step 2: Validate Cursor Syntax Against SQL Server 2025 Standards

  • Compare the cursor declaration against supported options: LOCAL, GLOBAL, FORWARD_ONLY, STATIC, KEYSET, DYNAMIC, FAST_FORWARD, READ_ONLY, SCROLL_LOCKS, OPTIMISTIC, TYPE_WARNING.
  • Remove any legacy or third-party options (e.g., options inherited from Sybase-style T-SQL) that are not part of the ISO syntax.
  • Rewrite ambiguous cursors using the ISO standard format instead of the Transact-SQL extended format to avoid option conflicts:
  DECLARE cursor_name CURSOR
  FOR SELECT_statement
  FOR READ ONLY

Step 3: Update Client Drivers and Connection Libraries

  • On Windows Server 2025 / Windows 11, open ODBC Data Sources (64-bit) via odbcad32.exe.
  • Verify the driver listed is ODBC Driver 18 for SQL Server or later; outdated drivers (like SQL Server Native Client) can generate malformed cursor requests.
  • Update via Microsoft Update Catalog or reinstall using:
  winget install Microsoft.ODBCDriverforSQLServer
  • Restart the application or service referencing the DSN after the update.

Step 4: Rebuild Stored Procedures with Corrected Cursor Logic

  • Use sp_helptext 'procedure_name' to extract the current procedure definition.
  • Edit and redeploy the procedure with corrected cursor syntax using ALTER PROCEDURE.
  • Recompile dependent objects with:
  EXEC sp_recompile 'procedure_name';

Alternative or Verification Steps

  • Run the corrected query manually in SQL Server Management Studio (SSMS) 20 or later and confirm it executes without raising Error 1073.
  • If the error persists, enable trace flag 7412 temporarily to capture lightweight query execution statistics and confirm the cursor is opening with the intended properties.