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

Troubleshooting Guide: Error 3964 – DDL Statement Not Allowed Inside Snapshot Isolation Transaction

Why This Error Happens

This error occurs because SQL Server 2025 does not support versioning metadata changes (such as CREATE, ALTER, or DROP statements) while running inside a transaction with SNAPSHOT isolation level active. Since the snapshot isolation engine relies on row versioning to maintain a consistent view of data, any DDL operation that modifies the schema conflicts with this versioned state because the metadata itself isn’t tracked in the version store. This typically happens when an application or script mixes schema-altering commands with SET TRANSACTION ISOLATION LEVEL SNAPSHOT in the same session or transaction block.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting DDL Statement

  • Review the SQL Server error log or SSMS output to pinpoint the exact query that triggered Error 3964.
  • Check if the transaction includes commands like ALTER TABLE, CREATE INDEX, DROP TABLE, or TRUNCATE TABLE.
  • Use sys.dm_tran_active_snapshot_database_transactions to confirm if an active snapshot transaction is open during the DDL call.

Step 2: Change the Isolation Level for the Session

  • Modify the application or stored procedure to switch isolation levels before executing DDL.
  • Run the following command prior to the DDL statement:
  SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
  • If the application requires snapshot isolation for reads, isolate the DDL logic into a separate connection or a new batch outside the snapshot transaction scope.

Step 3: Refactor Transaction Logic in the Application Code

  • Locate the connection string or ORM configuration (e.g., Entity Framework, Dapper) forcing snapshot isolation globally.
  • Update the .NET or ADO.NET connection settings to explicitly commit or roll back the snapshot transaction before opening a new connection for schema changes.
  • Ensure SET ALLOW_SNAPSHOT_ISOLATION OFF is not toggled mid-transaction, as this can also trigger metadata locking conflicts.

Step 4: Verify Database Compatibility Settings

  • Open SQL Server Management Studio (SSMS) and navigate to Database Properties > Options.
  • Confirm the Snapshot Isolation setting aligns with your intended workload (Allow Snapshot Isolation: True/False).
  • If snapshot isolation is not strictly required for the workflow, consider disabling it at the database level using:
  ALTER DATABASE [YourDB] SET ALLOW_SNAPSHOT_ISOLATION OFF;

Alternative or Verification Steps

  • To verify the fix, re-run the application transaction and monitor the SQL Server Profiler or Extended Events session for Error 3964; the DDL statement should now execute successfully under READ COMMITTED or outside the active snapshot context.
  • As an alternative, if snapshot isolation is mandatory for the application, restructure the workflow to execute all DDL changes during a maintenance window using a dedicated connection with AUTOCOMMIT mode, separate from the snapshot-isolated transaction scope.