Troubleshooting Guide: Error 3962 – “Bind to Another Transaction While Executing SQL Server Internal Query is Not Supported”
Why This Error Happens
This error occurs when SQL Server 2025 attempts to execute an internal query (often tied to a logon trigger) while the session is already bound to another transaction via sp_bindsession. The database engine cannot reconcile a transaction context switch mid-execution of system-level internal queries, causing the operation to fail. This is most commonly triggered by legacy connection pooling logic, distributed transaction coordination code, or third-party monitoring tools that use sp_bindsession to share transaction contexts across sessions.
Step-by-Step Resolution Guide
Step 1: Identify and Review Logon Trigger Definitions
- Open SQL Server Management Studio (SSMS) and connect to your SQL Server 2025 instance.
- Navigate to Server Objects > Triggers in Object Explorer to list all server-level logon triggers.
- Run the following query to extract trigger definitions for inspection:
SELECT name, OBJECT_DEFINITION(OBJECT_ID) AS definition
FROM sys.server_triggers;
- Look specifically for any calls to
sp_bindsession,sp_getbindtoken, or transaction-sharing logic within the trigger body.
Step 2: Remove or Refactor sp_bindsession Usage
- If
sp_bindsessionis found, comment it out or remove it entirely, as this procedure is deprecated and unsupported in modern distributed transaction scenarios. - Replace session-binding logic with modern alternatives such as
BEGIN DISTRIBUTED TRANSACTIONor Microsoft Distributed Transaction Coordinator (MSDTC) APIs if cross-session transaction sharing is required. - Save and redeploy the updated trigger using:
ALTER TRIGGER [TriggerName] ON ALL SERVER
FOR LOGON
AS
BEGIN
-- Updated logic without sp_bindsession
END;
Step 3: Check Application and Driver-Level Connection Pooling Settings
- Inspect your application’s connection string (especially if using ODBC, OLE DB, or .NET SqlClient) for any manual transaction enlistment flags.
- On Windows Server 2025 / Windows 11, open ODBC Data Source Administrator (
odbcad32.exe) and verify the driver version is updated to the latest SQL Server Native Client or Microsoft OLE DB Driver for SQL Server. - Disable any legacy “Transaction Binding” options in third-party middleware or ORM configurations (e.g., Entity Framework, JDBC) that may silently invoke
sp_bindsession.
Step 4: Restart SQL Server Service and Validate Startup Trigger Execution
- Open Services.msc on Windows Server 2025, locate “SQL Server (MSSQLSERVER)” or your named instance, and restart the service.
- Monitor the SQL Server Error Log (located by default at
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) during startup to confirm no logon trigger errors are thrown. - If the server fails to start due to a faulty logon trigger, start the instance in minimal configuration mode using:
sqlservr.exe -f -m
then disable the problematic trigger before restarting normally.
Alternative or Verification Steps
- Test a new login session via SSMS or
sqlcmdto confirm Error 3962 no longer appears in the SQL Server Error Log or client output. - If the error persists outside of logon trigger execution, check for third-party monitoring/auditing tools (e.g., APM agents) that may be injecting
sp_bindsessioncalls, and temporarily disable them to isolate the root cause.