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

Troubleshooting Guide: SQL Server Error 4083 – “Connection Recovered, Rowcount Not Available”

Why This Error Happens

This error occurs when SQL Server performs connection resiliency recovery after a transient network interruption (such as a dropped TCP session, firewall timeout, or cluster failover) between the client driver and SQL Server 2025. Because the original session’s transaction state could not be fully replayed on reconnection, the server discards the rowcount from the first query executed immediately after reconnection to preserve data integrity. This is a by-design safety mechanism of Idle Connection Resiliency, not a corruption or permissions issue, but it typically surfaces due to unstable network paths, aggressive firewall/NAT timeout settings, or load balancer session drops between the client and the Windows Server 2025 host.

Step-by-Step Resolution Guide

Step 1: Verify Network Stability Between Client and Server

  • Use ping -t <SQLServerIP> and tracert <SQLServerIP> over an extended period to check for packet loss or latency spikes.
  • Check Windows Event Viewer under Applications and Services Logs > Microsoft > Windows > TCPIP for dropped connection entries.
  • Confirm no intermediate firewall, VPN, or NAT device is silently closing idle TCP sessions (common default idle timeout is 300 seconds).

Step 2: Adjust Connection Resiliency and Timeout Settings

  • Open SQL Server Configuration Manager and verify the TCP/IP protocol is enabled for the correct instance.
  • In the client connection string, review the ConnectRetryCount and ConnectRetryInterval parameters (e.g., ConnectRetryCount=3;ConnectRetryInterval=10).
  • On Windows Server 2025, increase the TCP keep-alive interval via registry:
  • Path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  • Set KeepAliveTime (DWORD) to 30000 (30 seconds) and KeepAliveInterval to 1000.

Step 3: Re-Execute the Query to Confirm Rowcount Retrieval

  • Immediately after Error 4083 appears, run the exact same SELECT or UPDATE statement again.
  • Confirm that @@ROWCOUNT now returns a valid, non-null integer value.
  • Log the occurrence timestamp and cross-reference it with Step 1’s network logs to identify a pattern.

Step 4: Update SQL Server Native Client / ODBC Driver

  • Ensure you are using the latest Microsoft ODBC Driver 18+ for SQL Server or Microsoft.Data.SqlClient NuGet package compatible with SQL Server 2025.
  • Outdated drivers on Windows 11 client machines often mishandle the resiliency handshake, causing repeated 4083 errors even after a successful reconnect.

Step 5: Disable Connection Resiliency (If Troubleshooting Only)

  • As a diagnostic-only measure, temporarily set ConnectRetryCount=0 in the connection string to force a hard failure instead of a silent recovery.
  • This helps isolate whether the root cause is purely network-based or related to application-side transaction handling.

Alternative or Verification Steps

  • Verification: After implementing Step 2, monitor the application for 24–48 hours; if Error 4083 frequency drops to zero and @@ROWCOUNT consistently returns valid data on the first query, the fix is confirmed.
  • Alternative: If the error persists, bypass rowcount dependency entirely by using SCOPE_IDENTITY() or explicit OUTPUT clauses in your queries, which are unaffected by connection recovery rowcount loss.

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

Troubleshooting Guide: Error 4082 — Cannot Recover Session State in SQL Server 2025

Why This Error Happens

Error 4082 occurs when SQL Server’s session state manager cannot reconstruct or reattach the session context requested by a login, typically due to a mismatch between the client’s connection resiliency token and the server-side session cache. This commonly happens after an idle connection timeout, a failover event in an Always On Availability Group, or when the tempdb session state store becomes corrupted or prematurely truncated. It can also surface when Windows Server 2025’s updated TCP/IP stack drops a connection silently, leaving the SQL Server session table with a stale or orphaned entry.

Step-by-Step Resolution Guide

Step 1: Verify Connection Resiliency Settings

  • Check the client connection string for ConnectRetryCount and ConnectRetryInterval parameters; mismatched or overly aggressive retry settings can trigger premature session recovery attempts.
  • Run SELECT session_id, connect_time, login_time FROM sys.dm_exec_sessions WHERE is_user_process = 1; to confirm whether the original session still exists on the server.
  • If the session is missing entirely, the client is attempting to recover a session that SQL Server has already purged.

Step 2: Inspect and Rebuild tempdb Session State Store

  • Open SQL Server Configuration Manager and confirm tempdb data/log files are on a healthy, non-full volume (check via EXEC sp_spaceused inside tempdb).
  • Restart the SQL Server service (net stop MSSQLSERVER then net start MSSQLSERVER) to force a clean rebuild of tempdb, which clears corrupted session state entries.
  • If running a named instance, substitute MSSQLSERVER with MSSQL$<InstanceName>.

Step 3: Review Always On Availability Group Failover Logs

  • Open Failover Cluster Manager on Windows Server 2025 and check the Cluster Events log for recent automatic failovers around the error timestamp.
  • In SQL Server Management Studio, query SELECT * FROM sys.dm_hadr_availability_replica_states; to confirm the replica role is stable (not mid-transition).
  • If failovers are frequent, review the HADR_SYNC_COMMIT wait stats to rule out network latency causing session drops.

Step 4: Apply Latest Cumulative Update and Network Driver Patch

  • Navigate to Settings > Windows Update on Windows Server 2025 / Windows 11 and install any pending OS-level network stack patches.
  • Download and install the latest SQL Server 2025 Cumulative Update from the Microsoft Update Catalog, as this error has known fixes tied to session cache handling in early builds.
  • Reboot the server after patching to ensure the TCP/IP stack and SQL Server service reinitialize cleanly.

Step 5: Reset Client-Side Connection Pooling

  • In the application’s connection string, add Pooling=False temporarily to test if stale pooled connections are causing the session mismatch.
  • Clear the connection pool manually via SqlConnection.ClearAllPools() (if using .NET) or restart the application’s connection middleware/service.

Alternative or Verification Steps

  • To verify the fix, reproduce the original workload (reconnect after an idle period or trigger a test failover) and confirm no Error 4082 appears in the SQL Server Error Log (EXEC sp_readerrorlog 0, 1, 'Error: 4082').
  • If the issue persists, as a workaround, disable connection resiliency entirely (ConnectRetryCount=0) on the client to force fresh logins instead of session recovery attempts.

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

Why This Error Happens

Error 4081 occurs when SQL Server’s query parser detects that a parameter is being used in a context that implies a table-valued parameter (TVP), but the parameter was either not explicitly declared with a user-defined table type or is being referenced incorrectly within a stored procedure or dynamic SQL batch. This typically stems from a mismatch between the declared parameter type and its actual usage (e.g., passing a scalar variable where a TVP is expected, or vice versa). It can also surface after an in-place upgrade to SQL Server 2025 if legacy T-SQL code relies on deprecated type inference behavior that is now stricter.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Parameter and Procedure

  • Open SQL Server Management Studio (SSMS) and locate the exact stored procedure or batch referenced in the error message.
  • Run the following to find recent compilations that triggered the error:
  SELECT * FROM sys.dm_exec_query_stats
  CROSS APPLY sys.dm_exec_sql_text(sql_handle)
  WHERE text LIKE '%YourProcName%';
  • Confirm whether the parameter in question (%.*ls in the message) is intended to be scalar or table-valued.

Step 2: Correct the Parameter Declaration

  • Open the procedure definition in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Scripts (or your source-controlled .sql file) and verify the READONLY keyword is present for any TVP:
  CREATE PROCEDURE dbo.MyProc
      @MyTable dbo.MyTableType READONLY
  AS ...
  • Ensure the user-defined table type (dbo.MyTableType) actually exists by checking:
  SELECT * FROM sys.table_types WHERE name = 'MyTableType';
  • If the type is missing or was dropped during migration, recreate it using CREATE TYPE.

Step 3: Rebuild and Recompile the Procedure

  • Force a recompile to clear any cached, outdated execution plans:
  EXEC sp_recompile 'dbo.MyProc';
  • Restart the SQL Server service via Services.msc or PowerShell:
  Restart-Service MSSQLSERVER -Force
  • Re-run the original query/application call that triggered Error 4081.

Step 4: Validate Compatibility Level Settings

  • Check the database compatibility level, as SQL Server 2025 may enforce stricter parsing rules under newer compatibility levels:
  SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDB';
  • If recently upgraded, temporarily test with a prior compatibility level (e.g., 160) to confirm the error is tied to new parser behavior, then adjust your TVP code to be compliant rather than permanently downgrading.

Alternative or Verification Steps

  • Verify the fix by executing the stored procedure manually in SSMS with a properly structured TVP variable and confirming no Error 4081 is returned.
  • If the issue persists, use SQL Server Profiler or Extended Events to trace the exact execution plan compilation step where the parameter type deduction fails, and compare it against a known-working procedure signature.

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

Troubleshooting Guide: SQL Server Error 4080 – Incorrect TDS Protocol Stream

Why This Error Happens

Error 4080 occurs when the SQL Server Native Client or ODBC driver sends a malformed TRACE TDS header, typically due to a mismatch between the client driver version and the SQL Server 2025 engine’s expected protocol version. This is commonly triggered by outdated connection drivers, corrupted network packets caused by MTU/packet fragmentation issues, or a misconfigured SQL Server Diagnostic Trace (Extended Events TDS tracing) that injects invalid header data into the stream. In some cases, third-party middleware or proxy software intercepting the TDS stream (such as load balancers) strips or alters header bytes, causing the engine to reject the connection.

Step-by-Step Resolution Guide

Step 1: Update and Verify Client Drivers

  • Confirm the client machine is using the latest ODBC Driver 19 (or newer) or OLE DB Driver for SQL Server, as older drivers are not fully compatible with SQL Server 2025’s TDS 8.0 protocol revisions.
  • Uninstall legacy “SQL Server Native Client (SNAC)” drivers if present, since they are deprecated and incompatible with newer TDS handshakes.
  • Re-run the connection string test using sqlcmd -S servername -U user -P password -C to validate basic connectivity before testing application-level connections.

Step 2: Disable Conflicting TDS Tracing or Extended Events

  • Open SQL Server Management Studio (SSMS) and navigate to Management > Extended Events > Sessions.
  • Check for any active sessions using the sqlserver.tds_trace or custom trace events; stop and delete sessions that may be malforming the header: DROP EVENT SESSION [TDS_Trace] ON SERVER;
  • Restart the SQL Server service via services.msc or run net stop MSSQLSERVER && net start MSSQLSERVER in an elevated Command Prompt.

Step 3: Inspect Network Path for Packet Fragmentation

  • Check if a firewall, proxy, or load balancer sits between the client and the SQL Server instance; bypass it temporarily to isolate the issue.
  • Verify the Network Interface Card (NIC) settings on Windows Server 2025 aren’t forcing Jumbo Frames mismatched with the switch MTU size (Control Panel > Network and Sharing Center > Adapter Settings > Advanced).
  • Run netsh int ipv4 show subinterfaces to check for MTU inconsistencies across the connection path.

Step 4: Reset the TDS Endpoint Configuration

  • Open SQL Server Configuration Manager, go to SQL Server Network Configuration > Protocols for MSSQLSERVER.
  • Disable and re-enable the TCP/IP protocol to force the endpoint to rebuild its listener configuration.
  • Confirm the TDS port (default 1433) isn’t being shared or intercepted by another service using netstat -ano | findstr :1433.

Alternative or Verification Steps

  • To verify the fix, establish a test connection via sqlcmd or SSMS and run a simple query (SELECT @@VERSION;) to confirm the TDS handshake completes without Error 4080 appearing in the SQL Server Error Log (Management > SQL Server Logs).
  • If the error persists, capture a Wireshark network trace filtered by tds protocol during the failed connection attempt to identify exactly which byte offset in the header is malformed, then compare it against Microsoft’s official TDS 8.0 specification document.

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

Troubleshooting Guide: SQL Server Error 4079 — Arithmetic Overflow During Data Stream

Why This Error Happens

This error occurs when SQL Server attempts to send a result set to the client, but a numeric value in the data stream exceeds the precision, scale, or byte-length boundaries defined for its data type (commonly decimal, numeric, float, or int conversions). It is frequently triggered by implicit data type conversions between mismatched client driver expectations and server-side column definitions, or by computed columns/aggregations (such as SUM, AVG, or multiplication operations) producing a result that overflows the target type during serialization. Corrupted or outdated client drivers (ODBC/OLEDB) can also misinterpret the byte stream, compounding the overflow condition.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Column or Expression

  • Run the query directly in SQL Server Management Studio (SSMS) to isolate which column triggers the error.
  • Use SELECT SQL_VARIANT_PROPERTY(column_name, 'Precision') and 'Scale' to inspect the actual precision/scale of suspect numeric columns.
  • Check computed columns or CAST/CONVERT operations within the query for mismatched target sizes.

Step 2: Adjust Data Type Precision and Scale

  • Increase the precision of the target decimal or numeric column, e.g.:
    ALTER TABLE dbo.YourTable ALTER COLUMN YourColumn DECIMAL(18,4);
  • For aggregate operations, explicitly cast intermediate results to a larger type:
    SELECT CAST(SUM(Amount) AS DECIMAL(38,6)) FROM dbo.Transactions;
  • Avoid implicit conversions by ensuring client-side variable types (in C#, Java, or PowerShell scripts) match the SQL Server column definitions exactly.

Step 3: Update and Reconfigure the Client Driver

  • Navigate to Control Panel > Administrative Tools > ODBC Data Sources (64-bit) on Windows 11 or Windows Server 2025.
  • Update the driver to the latest Microsoft ODBC Driver 18 for SQL Server or OLE DB Driver 19, downloadable via the Microsoft Download Center.
  • Re-test the connection string, ensuring Encrypt=yes;TrustServerCertificate=yes; is set if using newer driver versions with enhanced data streaming validation.

Step 4: Review SQL Server Configuration for Arithmetic Abort Settings

  • Open SSMS and run:
    SET ARITHABORT ON;
    SET ANSI_WARNINGS ON;
  • These settings ensure SQL Server raises errors immediately rather than silently truncating or passing malformed data downstream, making overflow sources easier to trace in query execution plans.

Alternative or Verification Steps

  • Re-run the original query or application process after applying type changes; confirm no Error 4079 appears in SQL Server Logs (Object Explorer > Management > SQL Server Logs) or Windows Event Viewer under Applications and Services Logs > MSSQLSERVER.
  • If the issue persists, use SQL Server Profiler or Extended Events to capture the exact statement and parameter values causing the overflow, then validate against the destination application’s expected schema (e.g., reporting tools like SSRS or Power BI that may impose stricter type-casting rules).

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

Troubleshooting Guide: SQL Server Error 4077 — sql_variant Collation Mismatch

Why This Error Happens

This error occurs when a sql_variant column stores character data using a collation that differs from the database’s or instance’s default collation, and an operation (such as a comparison, sort, or UNION) cannot implicitly resolve which collation to use. SQL Server 2025 requires explicit collation context when comparing or combining sql_variant values that originated from columns or variables with mismatched collations. This typically happens after a database restore from a server with a different default collation, or when linking tables from different instances via linked servers.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting Collations

  • Run SELECT SQL_VARIANT_PROPERTY(column_name, 'Collation') FROM table_name; to inspect the stored collation of the sql_variant value.
  • Compare this against your database default: SELECT DATABASEPROPERTYEX('YourDB', 'Collation');
  • Note any mismatch, especially after migrating databases to SQL Server 2025 on Windows Server 2025/Windows 11.

Step 2: Apply an Explicit COLLATE Clause

  • Modify the failing query to cast the sql_variant value explicitly, e.g.:
    SELECT * FROM table_name WHERE CAST(column_name AS NVARCHAR(100)) COLLATE DATABASE_DEFAULT = 'value';
  • For comparisons between two sql_variant columns, apply COLLATE DATABASE_DEFAULT to both sides of the expression.
  • Save and re-run the query to confirm the error no longer appears.

Step 3: Align Database and Instance Collations

  • Open SQL Server Management Studio (SSMS) and right-click the instance → Properties → General to check the server-level collation.
  • If the database was restored from another system, consider rebuilding the affected table with a consistent collation using:
    ALTER TABLE table_name ALTER COLUMN column_name sql_variant COLLATE DATABASE_DEFAULT;
  • Restart the SQL Server service via Services.msc (Windows Server 2025/Windows 11) if collation metadata needs to refresh.

Step 4: Update Linked Server or ETL Collation Settings

  • If the data originates from a linked server, open Linked Servers in SSMS → Properties → Server Options, and ensure “Collation Compatible” is set to True if collations match.
  • For SSIS/ETL pipelines, verify the data flow task’s collation metadata matches the destination database.

Alternative or Verification Steps

  • Re-run the original failing query/report in SSMS; successful execution without Error 4077 confirms the fix.
  • As an alternative, if widespread mismatches exist, export the sql_variant data to a staging table using CAST(... AS NVARCHAR) with explicit COLLATE DATABASE_DEFAULT, then re-import to normalize collation across the dataset.

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

Why This Error Happens

This error occurs when a column referenced in a query, indexed view, computed column, or full-text/XML operation uses a collation that is incompatible with the specific SQL Server feature being invoked, such as binary (BIN2) requirements for XML indexes or system-level comparisons. It frequently surfaces after a database or server collation change, a cross-database query involving mismatched collations, or when migrating a database from an older SQL Server instance into SQL Server 2025 without aligning collation settings. The underlying cause is a structural mismatch between the column’s defined collation and the collation SQL Server expects for the operation to execute deterministically.

Step-by-Step Resolution Guide

Step 1: Identify the Affected Column and Current Collation

  • Run SELECT name, collation_name FROM sys.columns WHERE object_id = OBJECT_ID('YourTableName'); to locate the exact column referenced in the error message (match the ID returned in the error text).
  • Cross-reference the column ID using SELECT column_id, name FROM sys.columns WHERE object_id = OBJECT_ID('YourTableName'); to confirm which column triggered Error 4078.

Step 2: Determine the Required Collation for the Operation

  • Check whether the operation requires a binary collation (e.g., Latin1_General_BIN2) — this is common for XML indexes, full-text indexing, and certain indexed views in SQL Server 2025.
  • Compare the database default collation using SELECT DATABASEPROPERTYEX('YourDatabaseName', 'Collation'); against the column-level collation to spot mismatches.

Step 3: Alter the Column to Use the Correct Collation

  • Open SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your Windows Server 2025 instance.
  • Run an ALTER statement similar to:
  ALTER TABLE YourTableName
  ALTER COLUMN YourColumnName NVARCHAR(100) COLLATE Latin1_General_BIN2;
  • Ensure no active indexes, constraints, or foreign keys reference the column before altering it; drop and recreate them afterward if necessary.

Step 4: Rebuild Dependent Objects

  • Drop and recreate any indexed views, full-text indexes, or XML indexes that depend on the altered column.
  • Use sp_refreshview 'YourViewName'; to refresh view metadata after the collation change.

Step 5: Restart the SQL Server Service (If Required)

  • Open Services.msc on Windows Server 2025 / Windows 11 and restart the SQL Server (MSSQLSERVER) service to clear cached execution plans referencing the old collation.
  • Alternatively, run DBCC FREEPROCCACHE; to force plan recompilation without a full service restart.

Alternative or Verification Steps

  • Re-run the original query or operation that triggered Error 4078; if it executes without error, the collation mismatch has been resolved.
  • If the issue persists, use sp_help 'YourTableName'; to audit all columns for collation consistency, and consider rebuilding the entire table with COLLATE DATABASE_DEFAULT applied uniformly across all character-based columns.

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

Troubleshooting Guide: Error 4076 — Database Collation Not Recognized by Older Client Drivers

Why This Error Happens

This error occurs when SQL Server 2025 introduces new collation versions (such as updated Unicode or UTF-8-based collations) that are not understood by outdated client-side drivers like older versions of OLE DB, ODBC, or the SQL Native Client. The ALTER DATABASE statement fails because the client library attempting to negotiate the connection cannot parse the new collation metadata being returned by the server. This is typically a compatibility gap rather than a server-side corruption issue, caused by a mismatch between the SQL Server engine version and the installed client connectivity components.

Step-by-Step Resolution Guide

Step 1: Identify the Outdated Client Driver

  • Check which application or tool is issuing the ALTER DATABASE command (e.g., SSMS, a legacy application, or a custom connection string).
  • Run SELECT @@VERSION; on the server to confirm you are on SQL Server 2025.
  • On the client machine, check installed driver versions via Control Panel > Programs > Programs and Features, looking for “Microsoft OLE DB Driver for SQL Server” or “ODBC Driver for SQL Server.”

Step 2: Update the Client Connectivity Components

  • Download and install the latest Microsoft OLE DB Driver 19+ or ODBC Driver 18+ for SQL Server from the official Microsoft Download Center.
  • On Windows 11 or Windows Server 2025, ensure the OS is fully patched via Settings > Windows Update, as some collation libraries are tied to OS-level ICU (International Components for Unicode) updates.
  • Restart the client application/service after driver installation to ensure the new DLLs are loaded into memory.

Step 3: Apply the Latest SQL Server Cumulative Update (CU)

  • Navigate to the SQL Server Installation Center and check Help > About in SSMS to verify the build number.
  • Download the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Update Catalog.
  • Install the update on the server to ensure collation metadata compatibility layers are current.

Step 4: Adjust the Database Collation (If Driver Update Isn’t Immediately Possible)

  • As a temporary workaround, change the target database collation to a legacy-supported version (e.g., SQL_Latin1_General_CP1_CI_AS) instead of a newer version-specific collation.
  • Run the following command to check current collation: SELECT DATABASEPROPERTYEX('YourDBName', 'Collation');
  • Use ALTER DATABASE YourDBName COLLATE SQL_Latin1_General_CP1_CI_AS; only if application compatibility allows for this change.

Alternative or Verification Steps

  • Verify the Fix: Re-run the original ALTER DATABASE statement from the client machine. If successful, check the Windows Event Viewer (Application Log) to confirm Error 4076 no longer appears.
  • Alternative Fix: If updating the driver is not feasible due to legacy application constraints, use a connection string parameter to force a specific TDS (Tabular Data Stream) version that bypasses the new collation negotiation requirements.

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

Troubleshooting Guide: SQL Server Error 4075 – Database Collation Not Recognized

Why This Error Happens

This error occurs when a client application connects to a SQL Server 2025 instance using a database collation (typically a new UTF-8 enabled or version-specific collation) that the installed client driver does not recognize. Older ODBC drivers, OLE DB providers, or native client libraries bundled with legacy applications are not updated to parse the newer collation metadata introduced in SQL Server 2025. This mismatch causes the USE statement to fail immediately upon connection, as the driver cannot negotiate the character encoding rules required by the database.

Step-by-Step Resolution Guide

Step 1: Identify the Current Client Driver Version

  • Open the application’s connection properties or check the ODBC Data Source Administrator (odbcad32.exe) on Windows Server 2025 / Windows 11.
  • Look for drivers named “SQL Server Native Client” (SNAC) or older “SQL Server” drivers, as these are frequently the root cause.
  • Run SELECT @@VERSION; on the server to confirm you are running SQL Server 2025 build numbers that support newer collations.

Step 2: Update the Microsoft ODBC Driver or OLE DB Provider

  • Download and install the latest Microsoft ODBC Driver 18 for SQL Server (or newer) from the official Microsoft Download Center.
  • Uninstall legacy drivers via Control Panel > Programs and Features if they conflict with the new installation.
  • Update the connection string in your application to explicitly reference the new driver, e.g.:
    Driver={ODBC Driver 18 for SQL Server};Server=...;Database=...;

Step 3: Verify the Database Collation Setting

  • Check the specific collation causing the issue by running the following query in SQL Server Management Studio (SSMS):
    SELECT name, collation_name FROM sys.databases WHERE name = 'YourDatabaseName';
  • If the collation is not strictly required to be the new UTF-8 variant (e.g., Latin1_General_100_CI_AS_SC_UTF8), consider reverting to a standard, backward-compatible collation if client updates are not feasible:
    ALTER DATABASE YourDatabaseName COLLATE SQL_Latin1_General_CP1_CI_AS;

Step 4: Apply Windows and SQL Server Cumulative Updates

  • Navigate to Settings > Windows Update on Windows Server 2025 to ensure the OS build is fully patched, as some collation libraries rely on OS-level Unicode tables.
  • Install the latest Cumulative Update (CU) for SQL Server 2025 via the SQL Server Installation Center to ensure server-side collation handling is synced with client-side expectations.

Alternative or Verification Steps

  • Verification: Restart the client application and attempt to execute USE YourDatabaseName; again via SSMS or the application interface; the connection should process without throwing Error 4075.
  • Alternative: If updating drivers is not immediately possible, create a secondary database or temporary table with a legacy-compatible collation (e.g., SQL_Latin1_General_CP1_CI_AS) to serve older clients while the primary database retains the newer UTF-8 collation.

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

Troubleshooting Guide: SQL Server Error 4074 – Result Set Column Limit Exceeded

Why This Error Happens

Error 4074 occurs when a query attempts to return a result set containing more than 65,535 columns, which exceeds the hard limit imposed by the TDS (Tabular Data Stream) protocol that client drivers use to communicate with SQL Server. This typically happens with dynamically generated queries, wide PIVOT operations, or applications that programmatically concatenate large numbers of columns via SELECT * across multiple joined tables. It is not caused by corruption or permissions — it is a protocol-level restriction that client libraries (ODBC, OLE DB, JDBC) enforce and cannot bypass.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Capture the exact query using SQL Server Profiler, Extended Events, or the application’s query log.
  • Check the SELECT statement for wildcard usage (SELECT *) across multiple joined or pivoted tables.
  • Confirm the column count by running the query in SSMS and checking the “Results” pane column header count, or use sys.dm_exec_describe_first_result_set.

Step 2: Reduce the Returned Column Count

  • Rewrite the query to explicitly select only required columns instead of using SELECT *.
  • If using PIVOT, limit the number of distinct values being pivoted into columns (consider pivoting in batches).
  • For dynamic SQL generation (common in reporting tools), add a validation check in the stored procedure to cap column count before execution:
  • IF (SELECT COUNT(*) FROM sys.dm_exec_describe_first_result_set(@sql, NULL, 0)) > 65535 RAISERROR(...)

Step 3: Refactor Schema or Application Logic

  • If the underlying table design relies on wide tables (e.g., sparse columns, EAV patterns), consider normalizing the schema into multiple narrower tables.
  • Replace extremely wide JOIN chains with separate queries executed individually and merged at the application layer instead of within SQL Server.
  • For reporting/BI tools (SSRS, Power BI, Excel), paginate column output or use row-based transposition instead of column-based transposition.

Step 4: Update Client Drivers and Connection Settings

  • Ensure you are using the latest ODBC Driver (18+) or OLE DB Driver (MSOLEDBSQL) compatible with SQL Server 2025 on Windows Server 2025 / Windows 11.
  • Check driver installation path: C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\{version}\
  • Reinstall or repair the driver via Settings > Apps > Installed Apps on Windows 11, or Programs and Features on Windows Server 2025, if corruption is suspected.

Alternative or Verification Steps

  • Re-run the original query after modification and confirm successful execution without Error 4074 in SSMS or the application log.
  • As a temporary workaround, split the result set into multiple smaller queries (each under 65,535 columns) and reassemble the data client-side using application code (e.g., C# DataTable merge or Python pandas concat).

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

Why This Error Happens

Error 4073 occurs when a stored procedure, function, or extended stored procedure attempts to return a varchar(max), nvarchar(max), or varbinary(max) value through an interface that does not support MAX-length data types. This is common with legacy Extended Stored Procedures (XPs) or certain CLR integrations where the underlying Open Data Services (ODS) API only supports fixed-length or traditional large object (LOB) types up to 8,000 bytes. It can also surface after upgrading databases to SQL Server 2025 where compatibility-level changes expose previously tolerated MAX-type mismatches in legacy code.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Object

  • Open SQL Server Management Studio (SSMS) and reproduce the error to capture the exact stored procedure or function name from the error message details.
  • Run the following query to locate procedures using MAX types in their return or output parameters:
SELECT o.name, p.name AS parameter_name, t.name AS type_name
FROM sys.parameters p
JOIN sys.objects o ON p.object_id = o.object_id
JOIN sys.types t ON p.user_type_id = t.user_type_id
WHERE t.name IN ('varchar', 'nvarchar', 'varbinary') AND p.max_length = -1;
  • Confirm whether the object is a standard T-SQL procedure, an Extended Stored Procedure (xp_), or a CLR function.

Step 2: Modify the Data Type Definition

  • If the object is a CLR or Extended Stored Procedure, replace the varchar(max) return type with a bounded type such as varchar(8000) or split the output into smaller chunks.
  • If it is a native T-SQL function, verify the calling context; some interfaces (like certain sp_executesql or OLE Automation calls) do not support MAX types as return values.
  • Update the procedure definition:
ALTER PROCEDURE dbo.YourProcedure
    @Result varchar(8000) OUTPUT
AS
BEGIN
    -- revised logic without MAX type dependency
END

Step 3: Rebuild and Test in a Non-Production Environment

  • Deploy the corrected object to a staging instance running SQL Server 2025 on Windows Server 2025 or Windows 11.
  • Run DBCC FREEPROCCACHE to clear any cached execution plans referencing the old parameter definition:
DBCC FREEPROCCACHE;
  • Re-execute the procedure/function manually to confirm Error 4073 no longer appears.

Step 4: Check Compatibility Level Settings

  • If the issue appeared after a database migration, verify the compatibility level:
SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • If necessary, temporarily set compatibility level back to the prior version to confirm this is the triggering factor:
ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 150;

Alternative or Verification Steps

  • Verify the fix by executing the corrected stored procedure/function from both SSMS and the application layer, confirming no MAX-type values are passed through unsupported interfaces.
  • If the error persists, review the SQL Server Error Log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for additional context, and consider rewriting the function to use OUTPUT parameters with bounded lengths instead of direct MAX-type return values.

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

Troubleshooting Guide: SQL Server Error 4072 — XP Callback Function Failure in UDF

Why This Error Happens

This error occurs because SQL Server does not allow extended stored procedures (XPs) to send result sets or data back to the client when they are invoked from within a user-defined function (UDF). UDFs are designed to be deterministic, data-returning expressions, so any attempt by an XP to use callback functions like srv_sendmsg or srv_senddone inside that context violates SQL Server’s execution model. This typically surfaces when legacy extended procedures (often custom-built .dll based XPs) are called from scalar or table-valued functions instead of stored procedures.

Step-by-Step Resolution Guide

Step 1: Identify the Offending UDF and Extended Procedure

  • Review the full error message to identify the specific XP name and the UDF that triggered the call.
  • Query sys.objects where type = 'FN' or type = 'TF' to locate the function definition.
  • Use SQL Server Profiler or Extended Events (xp_cmdshell, sp_statement_completed) to trace which UDF is invoking the XP.

Step 2: Refactor the Code to Remove XP Calls from UDFs

  • Move the extended procedure call out of the UDF and into a standard stored procedure (CREATE PROCEDURE).
  • If the UDF needs the XP’s output, restructure the logic so the stored procedure calls the UDF, rather than the reverse.
  • Example fix pattern:
  • Original (broken): UDF -> EXEC master..xp_customproc
  • Corrected: Stored Procedure -> EXEC master..xp_customproc -> calls UDF for calculation only

Step 3: Audit and Update the Extended Procedure DLL

  • Check the XP’s source code (if available) for calls to srv_sendmsg, srv_senddone, or srv_sendrow.
  • Place these calls behind a context check using srv_rpcdb() or validate the caller context before attempting to send data.
  • Recompile the .dll and redeploy it to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\ on Windows Server 2025 / Windows 11.

Step 4: Restart the SQL Server Service and Clear Cached Plans

  • Open SQL Server Configuration Manager and restart the SQL Server (MSSQLSERVER) service to reload the updated XP DLL.
  • Run DBCC FREEPROCCACHE to clear any cached execution plans referencing the old UDF/XP relationship.
  • Re-run the original query or application process that triggered Error 4072.

Alternative or Verification Steps

  • Verify the fix by executing the stored procedure (not the UDF) directly in SSMS and confirming the XP returns data without throwing Error 4072 in the SQL Server Error Log.
  • If refactoring isn’t immediately possible, as a temporary workaround, replace the legacy extended procedure with a CLR Integration stored procedure, since CLR routines handle data output context more safely than classic XPs when called from nested objects.

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

Troubleshooting Guide: SQL Server Error 4071 (XP Callback Failure in INSERT-EXEC)

Why This Error Happens

This error occurs because SQL Server restricts extended stored procedures executed inside an INSERT...EXEC statement to returning only a single result set—no print messages, error messages, or output parameters are permitted through the XP callback interface. The conflict typically arises when a legacy extended procedure (such as a custom XP or xp_cmdshell-style wrapper) attempts to send informational messages via srv_message or similar ODS API calls while its output is simultaneously being captured by the INSERT...EXEC construct. This is a protocol-level limitation enforced by the SQL Server Open Data Services (ODS) layer, not a permissions or connectivity issue.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Extended Procedure and Query

  • Capture the exact query text using Extended Events (sqlserver.error_reported filtered on Error = 4071) or by reviewing the SQL Server error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • Note the extended procedure name referenced in the error message (the %.*ls placeholder will resolve to the actual XP name, e.g., xp_myCustomProc).
  • Confirm whether the call is wrapped in INSERT INTO #TempTable EXEC xp_myCustomProc.

Step 2: Refactor the Code to Avoid INSERT-EXEC with XPs

  • Rewrite the extended procedure call to execute standalone (without INSERT...EXEC), and instead have the XP write directly to a table using an internal SQLExecDirect/ODBC call from within the C/C++ XP code if you control its source.
  • If you do not control the XP source, modify the calling T-SQL batch to capture output using OLE Automation Procedures (sp_OACreate) or a CLR Table-Valued Function instead of INSERT...EXEC.
  • Example safe pattern:
  EXEC xp_myCustomProc;
  -- Avoid: INSERT INTO #Temp EXEC xp_myCustomProc;

Step 3: Update or Patch the Extended Procedure DLL

  • Check the vendor or internal development team for an updated build of the XP DLL that suppresses srv_message calls when invoked in a result-set-only context.
  • Locate the DLL under C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\ and verify version/timestamp against the vendor’s latest release.
  • Replace the DLL, restart the SQL Server (MSSQLSERVER) service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER, and re-test.

Step 4: Enable Trace Flag for Diagnostic Logging (Optional)

  • Add Trace Flag 3621 or enable verbose XP logging temporarily via SQL Server Configuration Manager under Startup Parameters to capture more context on which callback (print, error, or message) triggered the failure.
  • Remove the trace flag once root cause is confirmed, as it adds overhead.

Step 5: Migrate Away from Legacy Extended Procedures

  • Evaluate replacing the extended procedure entirely with a CLR Integration stored procedure, which natively supports structured result sets without ODS callback restrictions.
  • Enable CLR integration if not already active:
  EXEC sp_configure 'clr enabled', 1;
  RECONFIGURE;

Alternative or Verification Steps

  • Re-run the original query outside of INSERT...EXEC (standalone EXEC) to confirm the XP executes cleanly and the 4071 error does not reproduce.
  • If immediate remediation isn’t possible, wrap the XP call in a stored procedure that uses SET NOCOUNT ON and suppresses PRINT/RAISERROR statements internally, then validate via SQL Server Profiler/Extended Events that no error-class messages are emitted during the INSERT...EXEC execution.

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

Why This Error Happens

Error 4069 occurs when a stored procedure terminates execution before it can assign a value to a declared OUTPUT parameter, causing SQL Server to return NULL instead of the expected result. This is typically triggered by an unhandled exception, a RAISERROR/THROW statement firing mid-procedure, or a RETURN statement being hit prematurely due to faulty conditional logic. It can also occur if the calling application’s connection is reset (via CONTEXT_INFO or session state changes) while the batch is still executing on SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Review the Stored Procedure Logic

  • Open the procedure definition in SQL Server Management Studio (SSMS) using sp_helptext 'YourProcedureName';
  • Check every IF/ELSE branch to confirm the OUTPUT parameter is assigned a value (e.g., SET @OutParam = @Value;) before any RETURN statement is reached.
  • Pay close attention to TRY...CATCH blocks, as an error in the TRY block often skips the assignment logic entirely.

Step 2: Implement Default Value Initialization

  • At the very top of the stored procedure, immediately after the parameter declaration, initialize the output parameter to a safe default (e.g., SET @OutParam = 0; or SET @OutParam = '';).
  • This prevents a NULL value from propagating if an unexpected code path or early exit occurs later in the script.

Step 3: Check for Premature Connection Termination

  • Open Windows Server Manager or Event Viewer on Windows Server 2025 and navigate to Applications and Services Logs > Microsoft > SQL Server.
  • Look for correlating timeout errors or killed sessions (SPID) that align with the timestamp of the 4069 error.
  • If using a .NET or ODBC driver, verify the CommandTimeout property in the connection string is set higher than the expected execution time of the stored procedure to prevent the client from cutting the connection early.

Step 4: Validate CATCH Block Handling

  • Modify the CATCH block to explicitly set the output parameter to NULL or a specific error code (e.g., -1) before re-throwing the error.
  • Use the following syntax inside the CATCH block to ensure a value is always returned:
  SET @OutParam = -1;
  THROW;

Alternative or Verification Steps

  • Verification: Execute the stored procedure manually in SSMS using a DECLARE and EXEC block, then run PRINT @OutParam; immediately after execution to confirm a non-NULL value is returned under normal and error-forced conditions.
  • Alternative: If modifying the procedure is not immediately possible, update the client-side application code (C#/Java) to check for DBNull.Value on the parameter object before processing the result, preventing the application from crashing while you schedule a permanent SQL fix.

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

Troubleshooting Guide: SQL Server Error 4070 – “More Than 255 Columns Specified in the COMPUTE Clause”

Why This Error Happens

This error occurs because Transact-SQL enforces a hard limit of 255 columns within a single COMPUTE or COMPUTE BY clause, and your query attempts to exceed that threshold. It is typically caused by dynamically generated SQL, legacy reporting scripts, or ORM-generated queries that loop through table columns programmatically without accounting for this restriction. Since COMPUTE is a deprecated feature in modern SQL Server versions (including SQL Server 2025), this limitation is rigidly enforced and will not be increased in future updates.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Check the SQL Server Error Log or Extended Events session for the exact query text that triggered Error 4070.
  • Use SQL Server Management Studio (SSMS) 2025 to run the query manually and confirm the column count in the COMPUTE clause.
  • Look for dynamically generated SELECT * statements combined with COMPUTE SUM, COMPUTE AVG, or similar aggregate functions.

Step 2: Refactor the Query Using Modern T-SQL Syntax

  • Replace COMPUTE and COMPUTE BY with GROUP BY combined with ROLLUP, CUBE, or GROUPING SETS for aggregate calculations.
  • Example rewrite:
  • Old: SELECT * FROM Sales COMPUTE SUM(Amount)
  • New: SELECT *, SUM(Amount) OVER() AS TotalAmount FROM Sales
  • Use Window Functions (OVER(), PARTITION BY) as a direct, high-performance replacement for COMPUTE behavior.

Step 3: Update Application Code and Stored Procedures

  • Search all stored procedures using the built-in query:
  • SELECT * FROM sys.sql_modules WHERE definition LIKE '%COMPUTE%'
  • Update any ORM mappings (Entity Framework, Dapper) or reporting tools (SSRS) that may generate COMPUTE clauses automatically.
  • Deploy the updated stored procedures via SQL Server Management Studio or Azure Data Studio.

Step 4: Restart the SQL Server Service (If Cached Execution Plans Persist)

  • Open Services.msc on Windows Server 2025.
  • Locate SQL Server (MSSQLSERVER) or your named instance.
  • Right-click and select Restart to clear cached execution plans that may still reference the old query structure.

Alternative or Verification Steps

  • Run DBCC FREEPROCCACHE in SSMS to ensure no stale execution plans referencing COMPUTE remain in memory, then re-execute the corrected query to confirm Error 4070 no longer appears.
  • If refactoring is not immediately feasible, temporarily split the query into multiple smaller COMPUTE statements, each processing fewer than 255 columns, as a short-term workaround until the code is modernized.

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

Troubleshooting Guide: Error 4068 – “sp_resetconnection was sent as part of a remote procedure call (RPC) batch”

Why This Error Happens

This error occurs when a client driver (such as an outdated ODBC or OLE DB provider) attempts to bundle the internal sp_resetconnection call within the same RPC batch as a user-defined stored procedure call, which SQL Server 2025’s stricter protocol parser now rejects. It is typically triggered by legacy connection pooling logic in older client libraries that have not been updated to align with the TDS (Tabular Data Stream) protocol changes introduced in this release. Additionally, this can surface when middleware or connection pooling software reuses a connection improperly, sending a reset command alongside a batched procedure call rather than as a standalone operation.

Step-by-Step Resolution Guide

Step 1: Update Client Drivers and Connectivity Components

  • Navigate to the application server and check the installed version of msodbcsql.msi or Microsoft.Data.SqlClient via Control Panel > Programs and Features.
  • Download and install the latest Microsoft ODBC Driver (18.5 or higher) or update the NuGet package Microsoft.Data.SqlClient to version 6.0+ in your application project.
  • Restart the application pool or service referencing the driver (iisreset if applicable).

Step 2: Disable Connection Pooling Temporarily to Isolate the Issue

  • Open your application’s connection string configuration file (e.g., web.config, app.config, or appsettings.json).
  • Add or modify the parameter: Pooling=False; to test if the issue persists without pooled connections reusing the reset command improperly.
  • Monitor SQL Server logs at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for recurrence of Error 4068.

Step 3: Apply the Latest SQL Server 2025 Cumulative Update

  • Open SQL Server Configuration Manager and confirm the current build number via SELECT @@VERSION; in SQL Server Management Studio (SSMS).
  • Visit the Microsoft Update Catalog and download the latest Cumulative Update (CU) package for SQL Server 2025.
  • Run the installer as Administrator and follow the prompts to patch the instance, then restart the SQL Server (MSSQLSERVER) service via services.msc.

Step 4: Review and Correct Application-Level RPC Batching Logic

  • Inspect the application source code or stored procedure call wrapper for instances where sp_executesql or raw RPC calls are manually concatenated with reset logic.
  • Ensure that calls to stored procedures use parameterized SqlCommand objects with CommandType.StoredProcedure rather than raw batched SQL strings.
  • Remove any custom connection-reset wrapper code that manually injects sp_resetconnection into a batch.

Alternative or Verification Steps

  • To verify the fix, run a load test using SQL Server Profiler or Extended Events to capture RPC:Completed events and confirm sp_resetconnection no longer appears bundled with user procedure calls.
  • If the error persists after driver and CU updates, as a temporary workaround, configure the application’s connection pool to set Connection Lifetime=0 and Max Pool Size to a lower value to reduce aggressive connection reuse cycles.

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

Troubleshooting Guide: SQL Server Error 4067 — CLR Type Serialization Failed (Invalid Cookie)

Why This Error Happens

This error typically occurs when a CLR user-defined type (UDT) or user-defined aggregate becomes corrupted or mismatched due to an incomplete assembly update, a version mismatch between the serialized binary data and the registered CLR type metadata, or improper ALTER ASSEMBLY operations that did not fully synchronize type definitions. It can also happen if the assembly was deployed with PERMISSION_SET = UNSAFE or EXTERNAL_ACCESS without properly registering the native serialization format, causing SQL Server to reject the data cookie during deserialization. In some cases, this is triggered by database migration or restoration from an older SQL Server version where the CLR type binary layout is incompatible with SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify CLR Integration is Properly Enabled

  • Open SQL Server Management Studio (SSMS) and connect to your instance.
  • Run the following to confirm CLR is enabled:
  EXEC sp_configure 'clr enabled';
  • If disabled, enable it:
  EXEC sp_configure 'clr enabled', 1;
  RECONFIGURE;

Step 2: Rebuild and Redeploy the CLR Assembly

  • Drop the affected assembly and any dependent types:
  DROP TYPE IF EXISTS dbo.YourCLRType;
  DROP ASSEMBLY IF EXISTS YourAssemblyName;
  • Rebuild the .dll from source using Visual Studio 2022/2025 targeting the correct .NET Framework/CLR version supported by SQL Server 2025.
  • Redeploy the assembly from a trusted local path, e.g.:
  CREATE ASSEMBLY YourAssemblyName
  FROM 'C:\SQLAssemblies\YourAssembly.dll'
  WITH PERMISSION_SET = SAFE;
  • Recreate the CLR type:
  CREATE TYPE dbo.YourCLRType
  EXTERNAL NAME YourAssemblyName.[YourCLRType];

Step 3: Check for Version Mismatches After Migration or Restore

  • If the database was migrated or restored from an older SQL Server version, confirm the assembly binary matches the current CLR hosting version in Windows Server 2025.
  • Use the following query to inspect assembly metadata:
  SELECT * FROM sys.assemblies;
  SELECT * FROM sys.assembly_types;
  • If mismatched, drop and redeploy the assembly using Step 2 instead of relying on the restored binary.

Step 4: Validate Windows and SQL Server Patch Level

  • Confirm Windows Server 2025 / Windows 11 has the latest cumulative updates installed via Settings > Windows Update.
  • Confirm SQL Server 2025 is patched to the latest Cumulative Update (CU) using:
  SELECT @@VERSION;
  • Apply any pending CUs from the official Microsoft Download Center, as CLR serialization bugs are frequently addressed in these updates.

Alternative or Verification Steps

  • After redeployment, run a test query that inserts and retrieves data using the CLR type (e.g., SELECT CAST(... AS dbo.YourCLRType)) to confirm serialization/deserialization completes without Error 4067.
  • If the error persists, as a fallback, export the affected table data to a native SQL type (e.g., VARBINARY or NVARCHAR), drop the CLR type entirely, and rebuild the column using plain SQL types to bypass CLR serialization altogether.

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

Troubleshooting Guide: SQL Server Error 4066 — Type IDs Larger Than 65535

Why This Error Happens

This error occurs when SQL Server 2025 attempts to send metadata for types (such as user-defined types, table types, or system types with extended IDs) whose internal Type ID exceeds 65535 to a client driver that only understands the legacy TDS (Tabular Data Stream) protocol used by SQL Server 2000 or earlier. Because older client libraries (such as outdated versions of SQL Native Client, MDAC, or legacy ODBC/OLE DB drivers) allocate only a 16-bit field for Type IDs, they cannot parse the larger ID space introduced in modern SQL Server versions. This is fundamentally a protocol/client-compatibility mismatch rather than a server-side configuration defect.

Step-by-Step Resolution Guide

Step 1: Identify the Outdated Client Driver

  • Check the connection string or application configuration (ODBC DSN, OLE DB provider, or ADO connection) to determine which driver version is being used.
  • Run the following query on the server to capture client details from recent connections:
  SELECT session_id, client_interface_name, client_version, program_name
  FROM sys.dm_exec_sessions
  WHERE is_user_process = 1;
  • Look specifically for client_version values indicating SQL Server 2000 (version 8.x) or earlier.

Step 2: Upgrade the Client Connectivity Component

  • On Windows Server 2025 / Windows 11, download and install the latest Microsoft OLE DB Driver for SQL Server or ODBC Driver 18+ for SQL Server from the official Microsoft Download Center.
  • Uninstall legacy components via Control Panel > Programs > Programs and Features, specifically remove:
  • “Microsoft SQL Server Native Client”
  • “Microsoft Data Access Components (MDAC)” remnants if present.
  • Reinstall the application’s connectivity layer pointing to the updated driver.

Step 3: Update the Application’s Connection String

  • Modify the DSN or connection string to explicitly reference the new provider, for example:
  Provider=MSOLEDBSQL19;Server=YourServerName;Database=YourDB;Trusted_Connection=yes;
  • Avoid using deprecated provider strings like SQLOLEDB or SQLNCLI, as these trigger legacy TDS negotiation.

Step 4: Restrict or Isolate Legacy Type Usage (If Upgrade Isn’t Possible)

  • If the client absolutely cannot be upgraded, avoid using data types or features that generate Type IDs beyond the legacy range (e.g., CLR user-defined types, newer system types, or large table-valued parameter type definitions).
  • Create a compatibility view or stored procedure that casts/returns only basic legacy-safe types (e.g., INT, VARCHAR, DATETIME) to that specific client application.

Step 5: Restart SQL Services and Validate Connectivity

  • Restart the SQL Server service via:
  net stop MSSQLSERVER && net start MSSQLSERVER
  • Re-run the client application to confirm Error 4066 no longer appears in the SQL Server Error Log (Event Viewer > Applications and Services Logs > MSSQLSERVER).

Alternative or Verification Steps

  • Verify the Fix: Reconnect using the updated client driver and execute a query touching the previously failing type; confirm no Error 4066 appears in sys.dm_exec_connections session logs.
  • Alternative Workaround: If legacy software cannot be replaced, deploy a middleware/API layer (e.g., a REST or gRPC service) between the old client and SQL Server 2025 so the legacy application never directly negotiates TDS with the new type system.

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

Why This Error Happens

Error 4065 occurs when a client application attempts to execute a procedure or function through the Open Data Services (ODS) layer that SQL Server does not recognize as a valid remote procedure call. This typically happens when a legacy extended stored procedure (xp_) or system procedure has been deprecated, renamed, or is being invoked with an incorrect calling convention from an ODBC/OLE DB driver. It can also surface when a third-party or custom application uses outdated driver libraries that attempt to call internal SQL Server procedures no longer exposed in SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Procedure Call

  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for the exact procedure name substituted into '%.*ls'.
  • Run SELECT * FROM sys.sysmessages WHERE error = 4065; to confirm the message template and correlate it with the Event Viewer entry under Windows Logs > Application.
  • Cross-reference the procedure name against sys.objects to see if it still exists: SELECT name FROM sys.objects WHERE name = '<procedure_name>';

Step 2: Update Client Drivers and Connection Strings

  • Open ODBC Data Source Administrator (search odbcad32.exe on Windows Server 2025 / Windows 11) and verify the driver version is ODBC Driver 18 for SQL Server or later.
  • Update any legacy OLE DB provider (SQLOLEDB) references in connection strings to MSOLEDBSQL19.
  • Restart the dependent application pool or service in IIS Manager or Services.msc after updating the driver.

Step 3: Validate Extended Stored Procedure Permissions

  • Confirm the login has EXECUTE permission: GRANT EXECUTE ON <procedure_name> TO [DOMAIN\User];
  • If the procedure is a custom extended stored procedure (xp_), ensure its DLL is still registered under C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\ and re-register it using sp_addextendedproc.
  • If the DLL is missing or corrupted, reinstall the component from the original vendor package.

Step 4: Enable Trace Flags for Deeper Diagnostics

  • Start SQL Server with trace flag 3656 to capture more verbose ODS call stack information:
  DBCC TRACEON (3656, -1);
  • Reproduce the error and review the enhanced log output in SQL Server Configuration Manager > SQL Server Logs.

Alternative or Verification Steps

  • Run DBCC TRACESTATUS(-1); to confirm active trace flags, then re-run the original application request to verify the error no longer appears in the SQL Server Error Log.
  • If the issue persists, use SQL Server Profiler (or Extended Events in SSMS) to capture the exact RPC call and compare it against Microsoft’s current list of supported system/extended stored procedures for SQL Server 2025, replacing any deprecated calls with their modern T-SQL equivalents.

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

Troubleshooting Guide: SQL Server Error 4063 – “Cannot Open Database”

Why This Error Happens

This error occurs when a login’s default database (or a database explicitly requested in the connection string) is either offline, dropped, renamed, or the login no longer has the necessary permissions to access it. SQL Server falls back to the user’s configured default database instead of throwing a hard connection failure. In many cases, this is caused by a database restore/detach operation that didn’t update the login mappings, or a mismatch between the login’s sid and the database user’s sid after a migration.

Step-by-Step Resolution Guide

Step 1: Verify the Database State and Existence

  • Open SQL Server Management Studio (SSMS) and connect to the instance via the Database Engine.
  • Run the following query to check if the database exists and its current status:
  SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabaseName';
  • If the state_desc shows OFFLINE, RESTORING, or SUSPECT, this confirms the database is inaccessible rather than a permissions issue.

Step 2: Check and Fix Login Permissions

  • Identify the login causing the issue and its currently mapped default database:
  SELECT name, default_database_name FROM sys.sql_logins WHERE name = 'YourLoginName';
  • If permissions are missing, grant access to the database explicitly:
  USE YourDatabaseName;
  CREATE USER [YourLoginName] FOR LOGIN [YourLoginName];
  • On Windows Server 2025, ensure the SQL Server service account (visible in Services.msc) has not lost NTFS permissions on the .mdf and .ldf files located typically in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.

Step 3: Reset the Login’s Default Database

  • If the mapped default database was deleted or renamed, reset it to a valid database (like master) to prevent future login failures:
  ALTER LOGIN [YourLoginName] WITH DEFAULT_DATABASE = [master];
  • This ensures that even if the target application database is temporarily down, the login can still authenticate into the instance.

Step 4: Repair Orphaned Users (SID Mismatch)

  • If the database was restored from a different server, the User SID might not match the Login SID, causing an “orphaned user” state. Run this to check:
  EXEC sp_change_users_login 'Report';
  • Fix the mismatch by remapping the user to the login:
  EXEC sp_change_users_login 'Auto_Fix', 'YourLoginName';

Alternative or Verification Steps

  • Verification: Attempt to connect to the specific database again using SSMS or sqlcmd -S ServerName -d YourDatabaseName. If the connection succeeds without reverting to master, the issue is resolved.
  • Alternative Fix: If the database remains corrupted, restore the specific database from the latest valid .bak file via SSMS > Restore Database, ensuring the “Overwrite the existing database (WITH REPLACE)” option is checked if the file is in a suspect state.

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

Troubleshooting Guide: SQL Server Error 4064 — “Cannot Open User Default Database. Login Failed.”

Why This Error Happens

This error occurs when a SQL Server login’s default database is either offline, dropped, corrupted, or the login no longer has valid access permissions to it. Windows Server 2025 and Windows 11 environments are particularly sensitive to this issue after in-place OS upgrades, where SQL Server service accounts may lose mapped permissions during the migration. Additionally, this can happen if the database was detached, renamed, or restored under a different name without updating the login’s default database property.

Step-by-Step Resolution Guide

Step 1: Identify the Login’s Default Database

  • Open SQL Server Management Studio (SSMS) using the SQLCMD mode or connect via sqlcmd -S servername -E -d master since the default database connection will fail otherwise.
  • Run the following query to check which database is causing the conflict:
  SELECT name, default_database_name FROM sys.server_principals WHERE name = 'YourLoginName';
  • Confirm whether the referenced database exists and is online by checking sys.databases.

Step 2: Reset the Default Database to Master

  • Execute the following T-SQL command to temporarily redirect the login to the master database, restoring login capability:
  ALTER LOGIN [YourLoginName] WITH DEFAULT_DATABASE = [master];
  • This bypasses the immediate login failure and allows administrative access to diagnose the original target database.
  • Verify the change took effect by re-running the query from Step 1.

Step 3: Repair or Restore the Target Database

  • Navigate to the SQL Server Configuration Manager and check if the database files (.mdf/.ldf) are present in the expected directory, typically located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.
  • If the database shows as “Suspect” or “Offline” in SSMS, attempt to bring it online using:
  ALTER DATABASE [YourDatabaseName] SET ONLINE;
  • If corruption is suspected, run DBCC CHECKDB('YourDatabaseName') to assess the extent of the damage before considering a restore from backup.

Step 4: Validate Windows Server 2025 Permissions

  • Open Services.msc and ensure the SQL Server (MSSQLSERVER) service account has not been reset to a default profile during a Windows Update or Server Core transition.
  • Confirm the service account has “Log on as a service” rights via secpol.msc under Local Policies > User Rights Assignment.
  • Restart the SQL Server service to apply any permission changes.

Alternative or Verification Steps

  • Verification: Attempt to log in via SSMS using the specific login credentials; if successful, run SELECT DB_NAME(); to confirm the session is landing in the correct default database.
  • Alternative Fix: If the original database cannot be recovered, create a new database with the same schema requirements and reassign it as the default using ALTER LOGIN [YourLoginName] WITH DEFAULT_DATABASE = [NewDatabaseName]; to restore user access immediately while data recovery continues in the background.

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

Troubleshooting Guide: SQL Server Error 4062 – “Cannot Open User Default Database”

Why This Error Happens

This error occurs when a login’s default database, as defined in sys.server_principals, is either offline, dropped, renamed, or restored under a different name, making it unreachable at connection time. It can also happen if the login lacks the necessary CONNECT permission on that specific database following a permissions change, security audit, or migration. SQL Server 2025 correctly falls back to master to prevent a hard connection failure, but any application expecting to land in the original user database will fail silently or throw application-level errors.

Step-by-Step Resolution Guide

Step 1: Identify the Problematic Login and Its Default Database

  • Open SQL Server Management Studio (SSMS) and connect to the instance using an admin account (or via sqlcmd if GUI access is blocked).
  • Run the following query to check the configured default database for the affected login:
  SELECT name, default_database_name 
  FROM sys.server_principals 
  WHERE name = 'YourLoginName';
  • Cross-reference the result against sys.databases to confirm whether the database exists and is ONLINE.

Step 2: Verify Database State and Availability

  • Check if the database is offline, suspect, or in recovery pending mode:
  SELECT name, state_desc 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • If the state is OFFLINE, bring it back online:
  ALTER DATABASE YourDatabaseName SET ONLINE;
  • If the database was renamed or dropped during a migration (common after moving to Windows Server 2025 clusters), confirm the correct current name and update records accordingly.

Step 3: Reset the Login’s Default Database

  • If the original database is permanently gone or renamed, repoint the login to a valid, existing database:
  ALTER LOGIN YourLoginName WITH DEFAULT_DATABASE = YourCorrectDatabaseName;
  • Ensure the login has at least CONNECT permissions on the new default database:
  USE YourCorrectDatabaseName;
  GO
  CREATE USER YourLoginName FOR LOGIN YourLoginName;
  GO

Step 4: Validate Permissions on the Target Database

  • Confirm the login is mapped correctly to a database user and has not been orphaned (a common issue after restoring a .bak file from a different server).
  • Run sp_change_users_login 'Report' (legacy instances) or use the newer orphaned user remediation script in SQL Server 2025 to repair broken SIDs:
  ALTER USER YourLoginName WITH LOGIN = YourLoginName;

Step 5: Restart the SQL Server Service (If Caching Persists)

  • If changes do not take effect immediately due to cached login sessions, restart the SQL Server service via Services.msc on Windows Server 2025/Windows 11.
  • Alternatively, use PowerShell to restart the specific instance:
  Restart-Service -Name 'MSSQLSERVER' -Force

Alternative or Verification Steps

  • Verify the Fix: Attempt to log in using SSMS or your application connection string and confirm you land directly in the intended database rather than master. You can also check the active session context using SELECT DB_NAME(); immediately after connecting.
  • Alternative Fix: If the original database cannot be recovered, update the application’s connection string to explicitly specify the Initial Catalog (database name) parameter, bypassing reliance on the server-side default database setting entirely.

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

Troubleshooting Guide: SQL Server Error 4061

Why This Error Happens

Error 4061 occurs when the login attempting to connect does not have an associated database it can access, either because the requested database is offline, has been dropped, or is still recovering. This also commonly happens when the login’s configured “default database” no longer exists or the login lacks the CONNECT permission on that database. As a result, SQL Server 2025 falls back to using the master database as a safety measure, which often fails silently for applications expecting a specific schema.

Step-by-Step Resolution Guide

Step 1: Verify the Database State

  • Open SQL Server Management Studio (SSMS) and connect using an admin account (e.g., sa).
  • Run the query: SELECT name, state_desc FROM sys.databases;
  • Check if the target database status reads ONLINE. If it reads RECOVERY_PENDING or SUSPECT, the database files may be corrupted or the drive path is missing.

Step 2: Check and Reset the Login’s Default Database

  • Expand Security > Logins in SSMS, right-click the specific login, and select Properties.
  • Look at the Default database dropdown field; if it points to a database that was deleted, change it back to master temporarily.
  • Alternatively, run this T-SQL command to fix it via query:
  • ALTER LOGIN [YourLoginName] WITH DEFAULT_DATABASE = [master];

Step 3: Validate User Permissions and Mapping

  • Navigate to User Mapping under the Login Properties window.
  • Ensure the checkbox next to the target database is checked, granting the login access.
  • Verify the user has the db_datareader or appropriate role assigned; a mismatch between the Login (Server level) and the User (Database level) often triggers this error even if the database is online.

Step 4: Restart SQL Server Services

  • Open the Services app (services.msc) on Windows Server 2025 or Windows 11.
  • Locate SQL Server (MSSQLSERVER) or the specific named instance.
  • Right-click and select Restart to clear any cached connection states or locks that might be blocking the database file.

Alternative or Verification Steps

  • Verification: Attempt to reconnect using SSMS or your application; if successful, run SELECT DB_NAME(); to confirm you are no longer defaulting to the master database.
  • Alternative: If the database file (.mdf) is missing from the disk, restore the database from the latest .bak file using the Restore Database wizard in SSMS, ensuring the file paths match the original server configuration.

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

Troubleshooting Guide: SQL Server Error 4060 – “Cannot Open Database Requested by the Login”

Why This Error Happens

Error 4060 typically occurs because the login attempting to connect does not have an associated user account or permissions within the target database, or the default database specified for that login no longer exists or is inaccessible. This can also happen if the database is still in a RESTORING, OFFLINE, or SINGLE_USER state, or if the database name was misspelled in the connection string. In some cases, orphaned SIDs (Security Identifiers) between the login and the database user mapping can trigger this failure even when the user technically “exists.”

Step-by-Step Resolution Guide

Step 1: Verify the Database Status and Existence

  • Open SQL Server Management Studio (SSMS) and connect using an administrative account (e.g., sa).
  • Run the following query to check the database state:
  SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabaseName';
  • Ensure the state_desc returns ONLINE. If it shows RESTORING or OFFLINE, you will need to restore the backup chain or bring the database back online manually.

Step 2: Check Login Permissions and Database Mapping

  • Navigate to Security > Logins in SSMS, right-click the specific login causing the error, and select Properties.
  • Go to the User Mapping tab and confirm the checkbox next to the target database is checked.
  • If the mapping is missing, add it manually or run:
  USE YourDatabaseName;
  CREATE USER [YourLoginName] FOR LOGIN [YourLoginName];
  • If the user already exists but is “orphaned,” repair the SID link using ALTER USER [YourLoginName] WITH LOGIN = [YourLoginName];.

Step 3: Correct Firewall and Default Database Settings

  • On Windows Server 2025, verify that the Windows Defender Firewall isn’t blocking the specific database instance port (though this usually throws a different error, misconfigured VLANs can sometimes cause intermittent connection drops that mimic 4060).
  • Check the login’s “Default Database” setting in Login Properties > General. If it points to a decommissioned database, change it back to master to allow the login to connect first, then troubleshoot the specific DB access.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc if configuration changes were made at the instance level.

Step 4: Review SQL Server Error Logs

  • Navigate to the default log path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG (path may vary based on the 2025 instance naming convention).
  • Look for specific sub-errors occurring alongside the 4060, such as “Login failed for user” combined with State codes (e.g., State 38 indicates the database does not exist, while State 5 indicates insufficient permissions).

Alternative or Verification Steps

  • Verify the Fix: Attempt to log in via SSMS using the specific SQL login (not Windows Auth) and explicitly select the problematic database from the “Connect to Database” dropdown in the Options tab.
  • Alternative Fix: If the user mapping continues to fail, drop the user from the database (DROP USER [YourLoginName]) and recreate it, then manually re-assign the necessary roles (e.g., db_datareader, db_datawriter) to rule out corrupted permission schemas.

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

Troubleshooting Guide: SQL Server Error 4038 – “Cannot find file ID %d on device ‘%ls'”

Why This Error Happens

This error occurs when SQL Server’s internal metadata (stored in sys.database_files or sys.master_files) references a file ID that no longer exists on the physical device, typically due to a corrupted or out-of-sync database file header. It commonly arises after an improper file shrink operation, a failed ALTER DATABASE command that removed a file, or physical disk corruption that damaged the file allocation map (FAM) pages. In rare cases, this also surfaces when a database is restored or attached using an outdated or mismatched set of files, causing SQL Server to look for a file ID that was dropped in a newer version of the database.

Step-by-Step Resolution Guide

Step 1: Verify Database File Consistency

  • Open SQL Server Management Studio (SSMS) and run SELECT file_id, name, physical_name, state_desc FROM sys.master_files WHERE database_id = DB_ID('YourDatabaseName');
  • Compare the returned physical_name paths against the actual files present in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.
  • Note any file_id referenced in the error (e.g., file ID 4) and confirm whether its corresponding .ndf or .ldf file is missing from disk.

Step 2: Take the Database Offline and Inspect for Orphaned File References

  • Run ALTER DATABASE YourDatabaseName SET OFFLINE WITH ROLLBACK IMMEDIATE; to safely stop active connections.
  • Check the SQL Server Error Log (via EXEC sp_readerrorlog; or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for prior entries indicating a failed shrink or file removal event.
  • If a .ndf secondary file was deleted or moved outside of SQL Server (e.g., via Windows File Explorer or a third-party backup tool), locate the original file from a recent backup.

Step 3: Restore the Missing File Reference

  • If you have the original physical file, bring the database back online and run: ALTER DATABASE YourDatabaseName MODIFY FILE (NAME = LogicalFileName, FILENAME = 'D:\SQLData\MissingFile.ndf');
  • If the file is permanently lost and no backup exists, remove the broken reference using: ALTER DATABASE YourDatabaseName REMOVE FILE LogicalFileName; (only valid if the file belonged to an empty filegroup).
  • For critical production data, restore the entire database from the last known good full backup plus transaction log backups using RESTORE DATABASE YourDatabaseName FROM DISK = 'E:\Backups\YourDatabaseName.bak' WITH NORECOVERY; followed by RESTORE LOG statements as needed.

Step 4: Run Integrity Checks

  • Bring the database back online with ALTER DATABASE YourDatabaseName SET ONLINE;
  • Execute DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to confirm no further file or page-level corruption exists.
  • Review the output for any Msg 8928 or Msg 8944 errors that may indicate deeper corruption requiring REPAIR_ALLOW_DATA_LOSS.

Alternative or Verification Steps

  • Confirm the fix by querying sys.database_files again and ensuring all listed physical_name paths resolve to existing files on disk, then run a test SELECT TOP 10 * FROM a table residing in the previously affected filegroup.
  • If restoring the file is not possible and the error persists, consider creating a brand-new database and migrating data via BCP export/import or SSIS packages to bypass the corrupted file structure entirely.

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

Troubleshooting Guide: SQL Server Error 4037 – MEDIANAME Mismatch

Why This Error Happens

Error 4037 occurs when SQL Server attempts to read a backup device (tape, file, or media set) and finds that the MEDIANAME value stored in the device header does not match the MEDIANAME specified in the RESTORE or BACKUP command (via the MEDIANAME = clause). This typically happens because the backup media was created with a different name (or no name at all), the backup file was overwritten/reused by another backup set, or the wrong physical device/file path was referenced in the command. It can also occur if a backup file was copied or renamed after creation, causing a mismatch between the expected logical identifier and the actual header metadata embedded in the file.

Step-by-Step Resolution Guide

Step 1: Verify the Actual MEDIANAME on the Device

  • Run the following T-SQL command against the backup file or device to inspect its true header metadata:
  RESTORE HEADERONLY FROM DISK = 'C:\Backups\YourBackupFile.bak';
  • Review the MediaName column in the result set to confirm the actual name stored on the device.
  • Cross-check this against the name you supplied in your RESTORE/BACKUP statement.

Step 2: Correct the MEDIANAME Clause in Your Script

  • Update your RESTORE or BACKUP command to use the exact MEDIANAME returned in Step 1.
  • Example corrected syntax:
  RESTORE DATABASE YourDB
  FROM DISK = 'C:\Backups\YourBackupFile.bak'
  WITH MEDIANAME = 'CorrectMediaNameHere', REPLACE;
  • If you do not need strict media validation, simply remove the MEDIANAME = clause entirely from the command.

Step 3: Check for File Reuse or Corruption

  • Confirm the backup file has not been overwritten by a different backup job pointing to the same path.
  • Use File Explorer or PowerShell to check file timestamps and size:
  Get-Item "C:\Backups\YourBackupFile.bak" | Select-Object Name, Length, LastWriteTime
  • If the file appears truncated or inconsistent with your backup schedule, restore from a known-good backup copy instead.

Step 4: Validate SQL Server Agent Job Configurations

  • Open SQL Server Agent > Jobs in SQL Server Management Studio (SSMS) on Windows Server 2025.
  • Inspect any maintenance plans or scripted jobs that reference MEDIANAME to ensure they are hardcoded correctly and not pulling stale variables from an old job step.
  • Update the job step command text to match the verified MEDIANAME or remove the parameter if media set validation isn’t required.

Alternative or Verification Steps

  • Re-run the RESTORE DATABASE command after applying the corrected MEDIANAME and confirm it completes without Error 4037.
  • As a quick workaround, strip the MEDIANAME parameter entirely from both your BACKUP and RESTORE scripts — SQL Server will bypass this validation check and proceed using only the file/device path.

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

Why This Error Happens

Message 4035 (“Processed %I64d pages for database ‘%ls'”) is an informational message generated during BACKUP, RESTORE, or DBCC CHECKDB operations in SQL Server 2025, and it typically surfaces as a symptom when the underlying operation terminates abnormally rather than being an error itself. The root cause is usually an interrupted I/O stream caused by insufficient NTFS permissions on the backup/data directory, a corrupted database page preventing the read from completing, or the SQL Server service account lacking access to the target volume on Windows Server 2025. In some cases, antivirus or Windows Defender real-time scanning locks the .bak or .mdf file mid-operation, causing the page count to halt unexpectedly.

Step-by-Step Resolution Guide

Step 1: Verify Service Account Permissions

  • Open Services.msc on Windows Server 2025 / Windows 11 and confirm the SQL Server (MSSQLSERVER) service is running under a valid domain or managed service account.
  • Navigate to the backup/data directory (e.g., D:\SQLData\Backups) and ensure “NT SERVICE\MSSQLSERVER” has Modify/Write permissions via right-click → Properties → Security.
  • Run icacls "D:\SQLData\Backups" in an elevated Command Prompt to confirm ACL entries.

Step 2: Run a Consistency Check to Identify Corruption

  • Execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; in SQL Server Management Studio.
  • Review the output for allocation or consistency errors that may have halted the page-processing operation.
  • If corruption is found, note the page ID and object ID for targeted repair.

Step 3: Exclude SQL Directories from Antivirus Scanning

  • Open Windows Security → Virus & threat protection → Exclusions on the Windows Server 2025 host.
  • Add exclusions for *.mdf, *.ldf, *.bak, and the full data/log/backup folder paths.
  • Restart the SQL Server service via net stop MSSQLSERVER && net start MSSQLSERVER to clear any locked file handles.

Step 4: Re-run the Backup or Restore Operation

  • Re-trigger the operation using BACKUP DATABASE [YourDatabaseName] TO DISK = 'D:\SQLData\Backups\YourDB.bak' WITH CHECKSUM, STATS = 10;
  • Monitor the SQL Server Error Log (Management → SQL Server Logs) in real time for confirmation that the full page count completes without interruption.

Alternative or Verification Steps

  • Confirm resolution by checking that the final message reports the expected total page count matching the database size, with no accompanying error codes (e.g., 823, 824) in the SQL Server Error Log.
  • If the issue persists, restore from a known-good backup to a test instance and run DBCC CHECKDB there to isolate whether the corruption is storage-related (check Windows Event Viewer → System log for Disk/NTFS warnings).

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

Troubleshooting Guide: SQL Server Error 4030 – Media Expiration Conflict

Why This Error Happens

This error occurs because SQL Server enforces a retention policy on backup media through the MEDIADESCRIPTION and expiration date metadata written to the backup header. When a backup device (tape or disk file) has an active expiration date set via EXPIREDATE or RETAINDAYS, SQL Server blocks any new BACKUP operation from overwriting that media until the specified date has passed. This is a protective mechanism, not a corruption issue, and most commonly happens when backup jobs reuse the same device name without accounting for retention settings, or when a FORMAT option was omitted on a backup set that still has life remaining.

Step-by-Step Resolution Guide

Step 1: Verify the Current Expiration Date on the Media

  • Open SQL Server Management Studio (SSMS) and connect to the instance via a new query window.
  • Run the following to inspect the backup set metadata:
RESTORE HEADERONLY FROM DISK = 'E:\Backups\YourFile.bak';
  • Check the ExpirationDate column in the result set to confirm whether the media is still within its retention window.

Step 2: Force an Overwrite Using the WITH Clause

  • If the backup content is no longer needed, explicitly override the expiration check in your backup script.
  • Use WITH FORMAT, INIT, SKIP to bypass expiration and retention checks on the next write:
BACKUP DATABASE [YourDB]
TO DISK = 'E:\Backups\YourFile.bak'
WITH FORMAT, INIT, SKIP, STATS = 10;
  • The SKIP option specifically disables the expiration date and backup set name checks that trigger Error 4030.

Step 3: Correct the Retention Settings in the Maintenance Plan

  • Open SQL Server Agent in SSMS and locate the relevant Maintenance Plan under Management > Maintenance Plans.
  • Edit the Back Up Database Task and check the Backup set will expire setting; adjust RETAINDAYS to 0 if indefinite overwrites are intended, or set a realistic value matching your retention policy.
  • Save and redeploy the plan, then manually trigger the job via SQL Server Agent > Jobs to confirm it executes without raising 4030.

Step 4: Check for Group Policy or File-Level Immutability (Windows Server 2025 / Windows 11)

  • Navigate to the backup folder (e.g., E:\Backups\) in File Explorer and right-click the .bak file to open Properties > Security.
  • Confirm the SQL Server service account has Modify/Write permissions, as Windows Server 2025’s stricter default ACLs can sometimes compound perceived “locked” media issues alongside the SQL-level expiration flag.
  • Run icacls "E:\Backups\YourFile.bak" from an elevated Command Prompt to audit permissions if the file was moved or restored from another system.

Alternative or Verification Steps

  • Re-run RESTORE HEADERONLY FROM DISK = 'E:\Backups\YourFile.bak'; after the fix — if the query returns without error and shows the new BackupStartDate, the overwrite succeeded.
  • As an alternative, bypass the existing media entirely by targeting a new file name or device (e.g., YourFile_New.bak) to avoid the expiration conflict without altering retention logic.

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

Troubleshooting Guide: SQL Server Error 4028 – “End of Tape Has Been Reached”

Why This Error Happens

This error occurs when SQL Server completes writing data to the current tape volume during a backup or restore operation and requires an additional tape to continue the process, but no additional media has been loaded into the drive. It commonly happens when the database or backup set being processed exceeds the physical storage capacity of a single tape cartridge. Additionally, this can occur if the tape drive hardware fails to signal proper media-change events back to SQL Server, or if the backup operation was configured without accounting for multi-volume sets in unattended/scheduled jobs.

Step-by-Step Resolution Guide

Step 1: Prepare and Insert the Next Tape Volume

  • Physically locate the tape labeled in the error message (the %ls placeholder will show the specific tape name/sequence number).
  • Remove the full tape from the drive bay and insert the next blank or designated tape in the sequence.
  • Ensure the new tape is not write-protected and is compatible with the drive firmware (check for LTO generation mismatches on Windows Server 2025 hardware).

Step 2: Resume the Backup/Restore Operation in SSMS or T-SQL

  • If running via SQL Server Management Studio (SSMS), click the Retry button on the prompt dialog to signal SQL Server that the tape has been swapped.
  • If running a scripted job via T-SQL, ensure your script includes the BLOCKSIZE and MEDIANAME parameters correctly to avoid mismatch errors upon tape swap.
  • For unattended jobs, verify that xp_cmdshell or the SQL Server Agent job step does not time out while waiting for manual intervention.

Step 3: Verify Tape Drive Hardware and Drivers

  • Open Device Manager on Windows Server 2025 and check the Tape drives node for any yellow warning icons.
  • Update the tape drive driver via Update driver > Search automatically for drivers or download the vendor-specific driver (e.g., IBM, Quantum, HPE).
  • Restart the Removable Storage service via services.msc to ensure Windows correctly detects the newly inserted media.

Step 4: Switch to Multi-File Backup Striping (Recommended Fix)

  • To avoid the need for physical tape swaps on large databases, modify your backup script to stripe the backup across multiple tape drives simultaneously if your server has more than one drive bay.
  • Alternatively, migrate the backup destination to a Virtual Tape Library (VTL) or disk-based backup to eliminate physical capacity limits entirely.
  • Update the backup command to include multiple TAPE = destinations in the BACKUP DATABASE syntax to allow parallel writing.

Alternative or Verification Steps

  • Verify the fix: Check the SQL Server Error Log or the Windows Event Viewer (Application Log) for Event ID 4028 to ensure the backup completed with a “Processed X pages” success message rather than terminating with a fatal error.
  • Alternative solution: If physical tape changes are consistently causing bottlenecks or failures, consider decommissioning the tape backup strategy in favor of Azure Blob Storage backup targets, which are natively supported in SQL Server 2025 and eliminate the “end of volume” limitation entirely.

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

Why This Error Happens

Error 4022 occurs when the SQL Server BCP (Bulk Copy Program) or BULK INSERT operation initiates a bulk load session, but the client application fails to transmit the expected data stream before the connection times out. This is typically caused by a mismatched file format definition, an interrupted network connection between the client and SQL Server 2025 instance, or a source file that was moved, locked, or corrupted mid-transfer. It can also occur when the format file (.fmt) specifies more columns or a different structure than the actual data file provides.

Step-by-Step Resolution Guide

Step 1: Verify the Source Data File and Path

  • Confirm the file path referenced in your BULK INSERT or bcp command is accessible from the SQL Server 2025 service account (not just your local user account).
  • Check file permissions: right-click the file/folder → Properties → Security → ensure NT SERVICE\MSSQLSERVER (or the custom service account) has at least Read access.
  • Test with a UNC path (e.g., \\ServerName\Share\datafile.csv) instead of a mapped drive letter, as mapped drives are often invisible to the SQL Server service context.

Step 2: Validate the Format File and Column Mapping

  • Open the .fmt file (if used) and compare the column count/order against the actual source file headers.
  • Regenerate the format file using:
  bcp YourDatabase.dbo.YourTable format nul -c -f YourTable.fmt -S YourServerName -T
  • Ensure field terminators (,, \t) and row terminators (\n, \r\n) in your BULK INSERT statement match the actual encoding of the file (check for CRLF vs LF mismatches, common when files originate from Linux-based ETL pipelines).

Step 3: Check Network Stability and Timeout Settings

  • On Windows Server 2025, open Server Manager → SQL Server Configuration Manager → SQL Server Network Configuration → confirm TCP/IP is enabled and not experiencing packet drops.
  • Increase the client-side command timeout in your application or SSMS query timeout settings (Tools → Options → Query Execution → Execution time-out) if large files are causing premature termination.
  • If using a linked server or remote client, run a ping -t or tracert test to rule out intermittent network latency during the bulk transfer window.

Step 4: Rebuild the Bulk Insert Statement with Explicit Options

  • Re-run the operation using explicit WITH options to rule out default assumption errors:
  BULK INSERT YourTable
  FROM 'C:\Data\YourFile.csv'
  WITH (
      FORMATFILE = 'C:\Data\YourTable.fmt',
      FIRSTROW = 2,
      TABLOCK,
      ERRORFILE = 'C:\Data\ErrorLog.txt'
  );
  • Review the generated ErrorLog.txt for row-specific failures that may indicate truncated or empty data batches.

Alternative or Verification Steps

  • Run the bulk load against a small sample file (5–10 rows) first; if it succeeds, the issue is almost certainly a data/format mismatch rather than a permissions or network problem.
  • As an alternative, use SQL Server Import and Export Wizard or SSIS instead of raw BULK INSERT/bcp, as it provides better column-mapping validation and clearer error diagnostics for Windows 11 client-to-server transfers.

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

Troubleshooting Guide: SQL Server Error 4027 – “Mount tape for %hs of database ‘%ls’ on tape drive ‘%ls'”

Why This Error Happens

This error occurs when SQL Server 2025 initiates a backup or restore operation targeting a physical tape device but cannot proceed because it is waiting for an operator to mount the correct tape volume. The underlying cause is typically that the tape drive is either empty, contains the wrong volume, or the SQL Server Service Account lacks the necessary permissions to communicate with the tape hardware/driver. In some cases, this is also triggered by a misconfigured or orphaned backup device pointing to a non-existent or offline tape resource.

Step-by-Step Resolution Guide

Step 1: Verify Physical Tape Drive Status and Connectivity

  • Check the physical tape drive on the Windows Server 2025 host to ensure it is powered on and connected via the correct SAS/Fibre Channel interface.
  • Open Device Manager on the host and look under “Tape drives” to confirm the OS recognizes the hardware without a yellow warning icon.
  • If the drive is missing, reseat the hardware connection or update the tape drive drivers via the manufacturer’s latest Windows Server 2025 compatible package.

Step 2: Insert or Replace the Correct Tape Media

  • Since this specific error is a “prompt” rather than a hard failure, confirm that a blank or appropriately overwritable tape is physically loaded into the drive.
  • If using a tape library/autoloader, check the magazine slots to ensure the barcode-labeled tape requested by the backup job is actually present in the robotic arm’s accessible queue.
  • Run RESTORE LABELONLY FROM TAPE = '\\.\Tape0' in SQL Server Management Studio (SSMS) to verify the drive can read the currently inserted media header.

Step 3: Validate SQL Server Service Account Permissions

  • Navigate to Services.msc on Windows Server 2025 and locate the “SQL Server (MSSQLSERVER)” service.
  • Ensure the “Log On As” account has been granted Read/Write access to the tape device path (e.g., \\.\Tape0) via local security policy.
  • Add the service account to the local Backup Operators group to ensure it has the SeBackupPrivilege and SeRestorePrivilege rights required to interface with removable storage.

Step 4: Update the Backup Job Configuration

  • If the tape drive has been replaced or renamed in the Windows OS, update the legacy T-SQL script or SQL Agent Job step.
  • Modify the BACKUP DATABASE syntax to reflect the current, active tape drive letter/path:
  BACKUP DATABASE [YourDB] TO TAPE = '\\.\Tape0' WITH NOREWIND, NOUNLOAD;
  • Ensure the NOUNLOAD parameter is used if you intend to keep the tape mounted for sequential multi-database backups to avoid repeated mount prompts.

Alternative or Verification Steps

  • Verification: Once the tape is loaded and permissions are updated, re-run the specific backup job via SQL Server Agent; the job history should show a “Succeeded” status without triggering the Error 4027 mount prompt.
  • Alternative: If physical tape hardware continues to fail intermittently, consider migrating the backup strategy to a Virtual Tape Library (VTL) or standard disk-based backup (TO DISK =) to eliminate physical media handling errors entirely.

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

Troubleshooting Guide: SQL Server Error 4021 — Connection Reset Results in Different Login State

Why This Error Happens

Error 4021 occurs when SQL Server’s connection resiliency feature attempts to reset a session after an idle or dropped connection, but the session-level settings (such as database context, SET options, or temporary objects) cannot be restored to match the original login state. This typically happens due to changes in default database availability, mismatched collation or language settings applied mid-session, or interference from connection pooling in the client driver (such as an outdated ODBC or OLE DB provider). It can also be triggered when Contained Database Users or Azure AD/Entra ID authentication tokens expire mid-session on Windows Server 2025 environments.

Step-by-Step Resolution Guide

Step 1: Verify the Default Database State

  • Open SQL Server Management Studio (SSMS) and run SELECT name, state_desc FROM sys.databases; to confirm the user’s default database is ONLINE and not RESTORING or OFFLINE.
  • Check sp_helplogin 'username' to ensure the default database assigned to the login still exists and hasn’t been renamed or dropped.
  • If the default database is unavailable, reassign it using ALTER LOGIN [username] WITH DEFAULT_DATABASE = [master];

Step 2: Update Client Drivers and Connection Strings

  • Navigate to Control Panel > Programs > Programs and Features on the Windows Server 2025/Windows 11 machine and check the version of “Microsoft ODBC Driver for SQL Server” or “Microsoft OLE DB Driver for SQL Server.”
  • Download and install the latest driver from the Microsoft Download Center if the version predates 18.x.
  • In the application’s connection string, disable aggressive connection pooling by setting Pooling=false; temporarily to isolate whether pooling is causing stale session resets.
  • Alternatively, add ConnectRetryCount=3;ConnectRetryInterval=10; to allow graceful retries instead of abrupt resets.

Step 3: Audit SET Options and Session Context Scripts

  • Open SQL Server Configuration Manager and review any Logon Triggers under Server Objects > Triggers in SSMS that might be altering session state (e.g., SET ANSI_NULLS, SET QUOTED_IDENTIFIER) inconsistently.
  • Run DBCC USEROPTIONS; immediately after connecting to compare active session settings against the expected defaults.
  • Disable any custom logon triggers temporarily using DISABLE TRIGGER [trigger_name] ON ALL SERVER; to test if they are the source of the state mismatch.

Step 4: Check Authentication Token Expiry (Azure AD/Entra ID)

  • If using Entra ID authentication, open Event Viewer on the Windows Server 2025 host and navigate to Applications and Services Logs > Microsoft > Windows > AAD.
  • Look for token expiration events that align with the timestamp of Error 4021.
  • Increase the token refresh interval in your application’s authentication library or switch to SQL Server native authentication for service accounts experiencing frequent resets.

Step 5: Restart SQL Server Services and Clear Connection Cache

  • Open Services.msc, locate “SQL Server (MSSQLSERVER)” or the named instance, and perform a restart to clear any cached session states.
  • Run DBCC FREESYSTEMCACHE('ALL'); in SSMS to purge stale connection and plan cache data that might be causing the mismatch.

Alternative or Verification Steps

  • To verify the fix, open a new connection in SSMS, run a test transaction that switches database context, then force a network interruption (e.g., briefly disable the network adapter) to confirm the connection resumes without triggering Error 4021.
  • If the issue persists, enable Extended Events with the error_reported event filtered for Error 4021 to capture the exact session state mismatch for deeper diagnosis with Microsoft Support.

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

Troubleshooting Guide: SQL Server Error 4020 — Invalid Default Date Order

Why This Error Happens

This error occurs when the dateorder configuration associated with a specific language ID in the syslanguages (or sys.syslanguages compatibility view) contains an invalid or corrupted value instead of a valid pattern like mdy, dmy, or ymd. This is typically caused by corruption in system catalog metadata, a botched collation/language upgrade during migration to SQL Server 2025, or manual tampering with language settings via sp_configure or direct system table edits. SQL Server detects the invalid entry at parse time and silently falls back to the mdy default to prevent a hard failure, but the underlying metadata issue remains unresolved.

Step-by-Step Resolution Guide

Step 1: Identify the Affected Language and Current Dateorder Value

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and connect to the instance reporting the error.
  • Run the following query to inspect language metadata:
  SELECT langid, name, alias, dateformat 
  FROM sys.syslanguages;
  • Look for any row where the dateformat column contains a value other than mdy, dmy, or ymd — this is the corrupted entry.

Step 2: Check the Default Language Setting at the Login and Server Level

  • Verify the server-wide default language:
  EXEC sp_configure 'default language';
  • Check if a specific login has a non-standard default language assigned:
  SELECT name, language 
  FROM sys.server_principals 
  WHERE type = 'S';
  • If a login is tied to the corrupted language entry, temporarily reset it to us_english using:
  ALTER LOGIN [YourLoginName] WITH LANGUAGE = us_english;

Step 3: Repair or Reset the Corrupted Language Entry

  • If a custom/regional language pack was installed manually (common in non-English Windows Server 2025 deployments), reinstall it using the official SQL Server 2025 language resource files located in:
    C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Resources\<LCID>\
  • If the corruption persists in system tables, run DBCC CHECKCATALOG against the master database to confirm catalog integrity:
  DBCC CHECKCATALOG;
  • As a last resort, rebuild the master database language definitions by re-running SQL Server Setup in repair mode (Setup.exe /ACTION=REPAIR) from the installation media.

Step 4: Restart the SQL Server Service

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Restart the SQL Server (MSSQLSERVER) service to ensure the corrected language metadata is reloaded into memory.
  • Confirm there are no residual Error 4020 entries in the SQL Server Error Log located at:
    C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG

Alternative or Verification Steps

  • Run SELECT @@DATEFORMAT; after reconnecting to confirm the session is now using the correct date order (should return 1 for mdy, 2 for dmy, etc., depending on your intended locale).
  • If the issue reappears only for specific client applications, check the connection string for an explicit Language parameter that may be overriding the server default — remove it and let the login’s default language setting take precedence.

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

Troubleshooting Guide: SQL Server Error 4019 — Invalid Login Language

Why This Error Happens

This error occurs when a login (either in the connection string, application configuration, or user default settings) specifies a LANGUAGE value that does not match any entry in SQL Server’s sys.syslanguages system table. This commonly happens after a SQL Server upgrade/migration (such as moving to SQL Server 2025) where the Language Resource files were not fully installed, or when a default language was manually set via ALTER LOGIN using a typo or deprecated language name (e.g., using regional variants that were deprecated in newer builds). It can also occur if the server’s default language setting was corrupted during a collation change or master database restore from an incompatible version.

Step-by-Step Resolution Guide

Step 1: Identify the Invalid Language String

  • Open SQL Server Management Studio (SSMS) and connect using a Windows Admin account (since the SQL login itself may be broken).
  • Run the following query to see all valid languages recognized by the instance:
  SELECT * FROM sys.syslanguages;
  • Compare the output against the language name referenced in the error message (usually found in the SQL Server Error Log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).

Step 2: Correct the Login’s Default Language

  • Identify the broken login using:
  SELECT name, language FROM sys.sql_logins;
  • Reset the specific login to the server’s default language (usually us_english) using the ALTER LOGIN command:
  ALTER LOGIN [YourLoginName] WITH DEFAULT_LANGUAGE = [us_english];
  • If the application connection string is forcing a specific language via the Language keyword, update the connection string on the client machine or IIS configuration to remove the invalid parameter.

Step 3: Repair Missing Language Resources (Server-Side)

  • If sys.syslanguages is missing standard languages (indicating a corrupted installation), launch the SQL Server 2025 Installation Center from the original setup media.
  • Select Maintenance > Repair and choose the specific instance name on your Windows Server 2025 machine.
  • Allow the repair utility to restore the default language resource files located in the Binn directory, then restart the SQL Server (MSSQLSERVER) service via services.msc.

Step 4: Restart Services and Clear Cache

  • Restart the SQL Server service to ensure the language cache is reloaded into memory.
  • Open PowerShell as Administrator and run:
  Restart-Service -Name 'MSSQLSERVER' -Force
  • Attempt the login again using the previously failing credentials to confirm the queue has cleared.

Alternative or Verification Steps

  • Verification: Attempt to log in via SSMS using the specific login that previously failed; if successful, check the sys.dm_exec_sessions view to confirm the language column now displays a valid, officially supported name.
  • Alternative: If the repair fails to restore language files, manually drop and recreate the specific language using sp_addlanguage (though this is deprecated) or simply force all client applications to omit the Language parameter entirely, allowing SQL Server to default to the server-level setting.

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

Troubleshooting Guide: SQL Server Error 4018

Why This Error Happens

This error occurs when a login’s default language, as defined in sys.server_principals or sys.sql_logins, references a language name (syslanguages/sys.syslanguages) that has been removed, renamed, or was never properly registered on the SQL Server instance. This commonly happens after a server migration, an in-place upgrade to SQL Server 2025, or a restoration of logins from an older server instance where regional language packs differed. Since SQL Server cannot locate a matching entry in the sys.syslanguages catalog view, it silently falls back to the server-wide default language (typically us_english) and raises Error 4018 as a warning.

Step-by-Step Resolution Guide

Step 1: Identify the Affected Login and Its Configured Language

  • Open SQL Server Management Studio (SSMS) 21 or later and connect to the instance via Windows Authentication (sysadmin role required).
  • Run the following query to find logins with invalid default languages:
SELECT name, language 
FROM sys.syslogins 
WHERE language NOT IN (SELECT name FROM sys.syslanguages);
  • Note down the exact login names returned — these are the accounts triggering Error 4018.

Step 2: Verify Installed Languages on the SQL Server Instance

  • Run EXEC sp_helplanguage; to list all official language names recognized by this instance.
  • Compare the output against the language value found in Step 1 (common mismatches include British vs British English, or deprecated regional names from SQL Server 2016/2019).
  • Confirm the server-wide default language setting via:
EXEC sp_configure 'default language';

Step 3: Correct the Login’s Default Language

  • Use ALTER LOGIN to reset the affected login to a valid, officially supported language name:
ALTER LOGIN [YourLoginName] WITH LANGUAGE = N'us_english';
  • If managing multiple logins, script this change in bulk using a cursor over the result set from Step 1.
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER (PowerShell, run as Administrator) to clear cached session language settings.

Step 4: Re-check Server and Client Collation Settings

  • Navigate to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\ and confirm the sqlservr.exe version matches SQL Server 2025 build requirements.
  • Ensure client connection strings do not explicitly pass a deprecated Language= parameter in the connection string (common in legacy ODBC/OLEDB drivers).

Alternative or Verification Steps

  • Reconnect using the affected login and check the SSMS “Messages” tab — Error 4018 should no longer appear, and SELECT @@LANGUAGE; should return the corrected value.
  • If the error persists after altering the login, run DBCC FREEPROCCACHE to clear any cached execution plans referencing the old language metadata, then retry the connection.

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

Troubleshooting Guide: SQL Server Error 4017 – Language Mismatch Warning

Why This Error Happens

This warning occurs when the login’s requested language or the user’s default language setting does not match any of the official language names configured on the SQL Server instance (e.g., “us_english,” “French,” “Deutsch”). This typically happens due to a mismatch between the client connection string’s language parameter and the sys.syslanguages catalog, or because a user’s default language ID points to a language that was removed or was never installed correctly. While SQL Server gracefully falls back to the server-wide default language to maintain the connection, the root cause usually lies in misconfigured login properties or missing language packs.

Step-by-Step Resolution Guide

Step 1: Identify the Server’s Available Languages

  • Open SQL Server Management Studio (SSMS) and connect to the instance running on Windows Server 2025.
  • Run the following query to view all officially supported languages: EXEC sp_helplanguage;
  • Note the exact alias names (case-sensitive syntax matters for connection strings) listed in the result set.

Step 2: Verify the Login’s Default Language Setting

  • Query the specific login causing the error to check its configured default language:
  • SELECT name, language FROM sys.sql_logins WHERE name = 'YourLoginName';
  • If the language column is blank, NULL, or references a non-standard name, proceed to Step 3 to reset it.

Step 3: Correct the Login’s Default Language

  • Use the ALTER LOGIN command to explicitly set a valid language matching the alias found in Step 1.
  • Run: ALTER LOGIN [YourLoginName] WITH DEFAULT_LANGUAGE = [us_english];
  • If the application connection string is forcing a specific language via the Language keyword, update the connection string to match a valid sp_helplanguage alias exactly.

Step 4: Check Server-Wide Default Language Configuration

  • Verify the server’s default language ID using sp_configure 'default language';
  • If necessary, reconfigure the default language ID to ensure it points to a valid, installed language set (usually ID 0 for us_english) using sp_configure 'default language', 0; RECONFIGURE;
  • Restart the SQL Server service via the SQL Server Configuration Manager for the change to take full effect on Windows Server 2025.

Alternative or Verification Steps

  • Verification: Re-attempt the login connection via SSMS or the application; check the SQL Server Error Log (via EXEC sp_readerrorlog;) to confirm Error 4017 is no longer being generated for that specific login.
  • Alternative: If the error persists across multiple logins, consider reinstalling the specific Language Pack/Collation support feature via the SQL Server 2025 setup wizard, as this may indicate a corrupted syslanguages system table.

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

Troubleshooting Guide: SQL Server Error 4016

Why This Error Happens

Error 4016 occurs when a login attempts to connect to SQL Server 2025 using a @LANGUAGE value or client-configured language setting that does not match an official language name or alias registered in the sys.syslanguages (or sys.server_principals default language mapping) on the target instance. This commonly happens after a server migration, a mismatched regional/locale setting on the client driver, or when a login’s default language was set via a script referencing a language pack that was never installed on this particular SQL Server instance. Because SQL Server cannot resolve the requested language, it silently falls back to the user’s default language, but still raises this informational/warning event in the error log.

Step-by-Step Resolution Guide

Step 1: Identify the Requested vs. Available Languages

  • Open SQL Server Management Studio (SSMS) and connect to the instance via a working admin login.
  • Run EXEC sp_helplanguage; to list all official languages and aliases installed on this SQL Server 2025 instance.
  • Check the SQL Server Error Log (Management > SQL Server Logs) and locate the full Error 4016 text to identify the exact login name and the malformed language string being requested.

Step 2: Correct the Login’s Default Language Setting

  • Run EXEC sp_helpuser 'login_name'; or query sys.server_principals to check the current default_language_name assigned to the affected login.
  • Reset the login’s default language to a valid, officially supported value using:
  ALTER LOGIN [login_name] WITH DEFAULT_LANGUAGE = [us_english];
  • If the language should exist but doesn’t, verify the regional language pack was properly installed during SQL Server 2025 setup via Add/Remove Programs > Microsoft SQL Server 2025 Features.

Step 3: Fix the Client-Side Connection String or Driver Setting

  • On the client application or connection string (ODBC/ADO.NET/JDBC), remove or correct any explicit Language= parameter that references a non-standard or deprecated locale name (e.g., Language=Deutsch instead of the official German).
  • For applications using a SET LANGUAGE T-SQL command at session startup, update the script to use the exact name returned by sp_helplanguage.
  • Restart the application pool or client service and re-test the connection to confirm the explicit language request now resolves correctly.

Step 4: Review Group Policy and OS Regional Settings (Windows Server 2025 / Windows 11)

  • Check Control Panel > Region > Administrative > Language for non-Unicode programs on the client machine, as mismatched OS locale settings can sometimes propagate unexpected language strings to the driver.
  • Ensure the Windows Server 2025 instance hosting SQL Server has the correct regional and language pack installed under Settings > Time & Language > Language & Region.

Alternative or Verification Steps

  • Verify the fix by re-attempting the login and confirming Error 4016 no longer appears in the SQL Server Error Log; also run SELECT @@LANGUAGE; in a new session to confirm the correct language is now active.
  • If the issue persists, as a workaround, standardize all logins to use the server’s default language by running ALTER LOGIN [login_name] WITH DEFAULT_LANGUAGE = [your_server_default]; for every affected account, bypassing the need for per-login language resolution entirely.

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

Why This Error Happens

Error 4014 typically occurs when the SQL Server network connection between the client and server is unexpectedly interrupted at the TCP/IP packet level. This is often caused by network instability, a misconfigured firewall dropping packets mid-session, antivirus/deep packet inspection software interfering with the TDS (Tabular Data Stream) protocol, or corrupted network drivers on Windows Server 2025 / Windows 11. It can also stem from client-side connection timeouts conflicting with long-running queries or large result sets being transmitted over an unstable link.

Step-by-Step Resolution Guide

Step 1: Verify Network Stability and Firewall Rules

  • Run ping <SQLServerInstanceName> and tracert <SQLServerInstanceName> continuously to check for packet loss or latency spikes.
  • Open Windows Defender Firewall with Advanced Security and confirm inbound/outbound rules allow TCP port 1433 (default instance) and any dynamic ports used by named instances.
  • Temporarily disable third-party antivirus/firewall software to rule out deep packet inspection interference, then re-test the connection.

Step 2: Check SQL Server Network Configuration

  • Open SQL Server Configuration Manager → SQL Server Network Configuration → Protocols for [InstanceName].
  • Ensure TCP/IP is enabled and verify the correct IP address/port bindings under the IP Addresses tab.
  • Restart the SQL Server (MSSQLSERVER) service after any configuration changes via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.

Step 3: Update Network Drivers and Adapter Settings

  • Navigate to Device Manager → Network Adapters, right-click the active NIC, and select Update Driver.
  • Disable TCP Chimney Offload and Receive Side Scaling (RSS) if packet corruption is suspected, using PowerShell: Disable-NetAdapterChecksumOffload -Name "*".
  • Reboot the server/workstation to apply the driver and adapter changes cleanly.

Step 4: Adjust Client and Server Timeout Settings

  • In your client application or SSMS, increase the Connection Timeout and Query Timeout values under Tools → Options → Query Execution.
  • On the server side, review sp_configure 'remote query timeout' and adjust if queries are being prematurely terminated.
  • Apply changes with RECONFIGURE and restart the SQL Server service to ensure settings take effect.

Alternative or Verification Steps

  • Reproduce the original workload (large query/data transfer) and monitor the SQL Server Error Log and Windows Event Viewer (Application log) to confirm Error 4014 no longer appears.
  • If the issue persists, capture a network trace using Wireshark or Netmon during the failure window to identify the exact point of packet loss, and share the trace with your network team for deeper TCP-level analysis.

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

Troubleshooting Guide: SQL Server Error 4015 – Language Not an Official Name

Why This Error Happens

This informational error occurs when a login attempts to connect to SQL Server 2025 using a DEFAULT LANGUAGE setting (either at the login level or specified by the client connection string) that does not correspond to an officially installed language alias in the sys.syslanguages (or sys.server_principals) catalog. This typically happens after a server migration, a case-sensitive mismatch in the language name, or because a client-side application is hardcoding a regional language value (e.g., “British”) that was never installed or aliased on this specific instance. Since SQL Server cannot locate the matching langid, it safely falls back to the server-wide default language (usually us_english) to prevent the login from failing entirely.

Step-by-Step Resolution Guide

Step 1: Identify the Current Server Default Language

  • Open SQL Server Management Studio (SSMS) and connect to your instance via a sysadmin account.
  • Run the following query to check the current server default langid:
  EXEC sp_configure 'default language';
  • Note the run_value; this is the language ID currently being used as the fallback.

Step 2: Audit Official Language Names on the Instance

  • Query the system view to see exactly which names are “official” (aliases) versus simply display names.
  • Run this command to see the valid list of names SQL Server will accept for login configuration:
  SELECT langid, name, alias FROM sys.syslanguages;
  • Compare this list against the specific language string being passed in the connection string or login properties. Pay close attention to regional differences (e.g., “English” vs. “us_english”).

Step 3: Update the Login’s Default Language Property

  • Navigate to the specific login causing the error.
  • In SSMS, right-click the login under Security > Logins > [LoginName] > Properties > General.
  • Update the Default Language dropdown to a valid official name/alias found in Step 2.
  • Alternatively, fix this via T-SQL by executing:
  ALTER LOGIN [YourLoginName] WITH DEFAULT_LANGUAGE = [us_english];

Step 4: Check the Application Connection String

  • If the login itself is correctly configured but the error persists, the issue likely lies in the client application (e.g., a .NET or ODBC driver) explicitly setting SET LANGUAGE upon connection.
  • Locate the web.config, app.config, or connection pooling settings on the Windows Server 2025/Windows 11 client machine.
  • Remove any hardcoded Language= parameters from the connection string unless they exactly match an alias from the sys.syslanguages table.

Alternative or Verification Steps

  • Verify the Fix: Re-attempt the login connection and check the SQL Server Error Log (via SSMS or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\) to confirm Error 4015 is no longer being raised upon connection.
  • Alternative Fix: If specific regional languages are required but missing, you may need to reinstall the Language Pack component via the SQL Server 2025 setup media to register the missing syslanguages aliases before assigning them to the login.

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

Troubleshooting Guide: SQL Server Error 4013 — Incorrect TDS Protocol Stream / Missing MARS TDS Header

Why This Error Happens

This error occurs when the Tabular Data Stream (TDS) packets sent by the client do not conform to the structure SQL Server expects when Multiple Active Result Sets (MARS) is enabled on the connection. It is typically caused by a mismatch between the client driver version and the SQL Server 2025 engine, network-level packet corruption or fragmentation (often from misconfigured firewalls, proxies, or load balancers), or an outdated/corrupted client-side network library (such as an old ODBC or OLE DB driver) that does not properly format MARS session headers. In some cases, antivirus or deep packet inspection software intercepting the connection can also strip or alter TDS headers mid-stream.

Step-by-Step Resolution Guide

Step 1: Update and Verify Client Drivers

  • Ensure the client application is using the latest Microsoft ODBC Driver or OLE DB Driver compatible with SQL Server 2025.
  • On Windows 11 / Windows Server 2025, check installed driver versions via Control Panel > ODBC Data Sources (64-bit).
  • Uninstall legacy drivers (e.g., SQL Server Native Client) and replace with the current Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL) or ODBC Driver 18+.

Step 2: Inspect and Reset Network Path

  • Disable any proxy, SSL-inspection, or deep packet inspection (DPI) features on firewalls/antivirus that intercept SQL traffic on port 1433.
  • Run netstat -ano | findstr 1433 to confirm no unexpected intermediary process is binding to the SQL Server port.
  • If using a load balancer, confirm it is configured in “TCP pass-through” mode rather than re-packetizing TDS traffic.

Step 3: Validate MARS Configuration on the Connection String

  • Confirm the client connection string includes MultipleActiveResultSets=True only if the application logic actually requires concurrent result sets.
  • Remove or correct malformed MARS parameters, as inconsistent flags between client and server can trigger header mismatches.
  • Example corrected connection string:
    Server=myServer;Database=myDB;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;

Step 4: Restart SQL Server Services and Clear Session Cache

  • Open SQL Server Configuration Manager and restart the SQL Server (MSSQLSERVER) service to clear any corrupted session buffers.
  • Clear client-side connection pooling by restarting the application pool (IIS) or application service that hosts the database client.

Step 5: Check for Network Packet Fragmentation

  • Verify the Network Packet Size setting in SQL Server under Server Properties > Connections matches what the network infrastructure (MTU size) supports — default is 4096 bytes.
  • Run Test-NetConnection -ComputerName <SQLServerName> -Port 1433 on Windows 11/Server 2025 to confirm clean connectivity without timeouts or resets.

Alternative or Verification Steps

  • After applying the fixes, reproduce the original query/application action that triggered Error 4013 and confirm no TDS-related errors appear in SQL Server Error Logs (SQL Server Management Studio > Management > SQL Server Logs).
  • If the issue persists, capture a network trace using Wireshark or Network Monitor while reproducing the error to confirm whether TDS packets are being altered in transit by security middleware, and work with your network team to exclude SQL Server traffic from inspection rules.

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

Troubleshooting Guide: SQL Server Error 4012 – Invalid TDS Collation

Why This Error Happens

Error 4012 occurs when the Tabular Data Stream (TDS) packet sent to SQL Server 2025 contains a collation identifier that the server cannot recognize or map to a valid collation in its internal collation table. This typically happens due to a mismatch between client driver versions and the server’s collation set, a corrupted sqlncli or msodbcsql driver installation, or an outdated client library attempting to negotiate a collation introduced in a newer SQL Server version that the driver doesn’t understand. It can also surface after an in-place upgrade where system databases retain a legacy collation reference that conflicts with newly introduced server-level collation metadata.

Step-by-Step Resolution Guide

Step 1: Verify and Update Client Drivers

  • Confirm which driver the failing application uses (ODBC, OLE DB, or JDBC) via Event Viewer under Windows Logs > Application.
  • Download and install the latest Microsoft ODBC Driver or msodbcsql18.msi from the official Microsoft Download Center.
  • Restart the application pool or client service after installation to force driver reload.

Step 2: Check Server Collation Configuration

  • Open SQL Server Management Studio (SSMS) and run:
  SELECT SERVERPROPERTY('Collation');
  • Compare this output against the collation expected by the client connection string.
  • If mismatched, update the connection string or application config file (appsettings.json, web.config, or DSN entry) to explicitly specify the correct collation parameter.

Step 3: Rebuild or Repair System Databases

  • Open an elevated Command Prompt on Windows Server 2025.
  • Navigate to the SQL Server binn directory, typically:
  C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn
  • Run a repair install using the setup media:
  setup.exe /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=BUILTIN\Administrators /SAPWD=<StrongPassword>
  • This resets master, model, msdb, and tempdb collation metadata to a known-good state.

Step 4: Clear TDS Endpoint Cache and Restart Services

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Restart the SQL Server (MSSQLSERVER) and SQL Server Browser services to flush cached TDS negotiation parameters.
  • If using a named instance, restart the corresponding SQL Server (InstanceName) service as well.

Alternative or Verification Steps

  • Test the fix by connecting via sqlcmd -S <ServerName> -E -Q "SELECT @@VERSION" — a successful connection with no 4012 error confirms resolution.
  • If the error persists, create a new client alias using SQL Server Configuration Manager with explicit TCP/IP protocol settings and a matching collation flag to bypass any cached negotiation data.

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

Troubleshooting Guide: Error 4011 – Incorrect MARS TDS Header Stream

Why This Error Happens

This error occurs when Multiple Active Result Sets (MARS) is enabled on a connection and the underlying TDS packet stream becomes malformed or desynchronized, often due to network packet corruption, a faulty network driver, or an outdated client provider (such as an old ODBC or OLE DB driver) that mismanages concurrent batches. It can also surface when third-party network security software (antivirus/deep packet inspection) intercepts and modifies SQL Server traffic on port 1433, or when there is a mismatch between the client-side connection string MARS settings and the server’s session state. Additionally, corrupted or fragmented TCP packets caused by faulty NIC offloading settings (like TCP Chimney or RSS) on Windows Server 2025 can trigger this header corruption.

Step-by-Step Resolution Guide

Step 1: Update and Verify Client Drivers

  • Ensure the application is using the latest Microsoft OLE DB Driver or ODBC Driver 18+ for SQL Server, as older drivers have known MARS handling bugs.
  • Check the connection string to confirm MultipleActiveResultSets=True is explicitly set only if the application logic requires concurrent batches.
  • Restart the client application service after the driver update to clear cached connection pools.

Step 2: Disable NIC Offloading Features

  • Open PowerShell as Administrator on the Windows Server 2025 host.
  • Run Disable-NetAdapterChecksumOffload -Name "*" to rule out checksum calculation errors corrupting packets.
  • Run Set-NetAdapterAdvancedProperty -Name "*" -DisplayName "Receive Side Scaling" -DisplayValue "Disabled" to test if RSS is causing packet reordering issues.
  • Reboot the network adapter or server to apply changes.

Step 3: Flush Connection Pooling and Reset Sessions

  • Access SQL Server Management Studio (SSMS) and run DBCC FREESYSTEMCACHE('ALL') to clear corrupted cached execution plans associated with the bad session.
  • Kill any hanging SPIDs associated with the specific application using KILL [Session_ID].
  • If using .NET, ensure SqlConnection.ClearPool() is called within the application error handling to force a fresh TDS handshake.

Step 4: Inspect Antivirus and Firewall Packet Inspection

  • Navigate to Windows Defender Firewall with Advanced Security on the Windows Server 2025 machine.
  • Create an exclusion rule for the SQL Server process (sqlservr.exe) and port 1433 to bypass deep packet inspection (DPI) that might be altering TDS headers.
  • Temporarily disable third-party antivirus real-time scanning to test if it resolves the TDS stream corruption.

Alternative or Verification Steps

  • Verification: Use SQL Server Profiler or Extended Events to trace the Errors and Warnings event category; confirm that Error 4011 no longer appears during high-concurrency MARS transactions.
  • Alternative: If the error persists, disable MARS entirely in the connection string (MultipleActiveResultSets=False) as a temporary workaround while further investigating network hardware (switches/routers) for Jumbo Frame misconfigurations.

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

Troubleshooting Guide: Error 4010 – Incorrect TDS Protocol Stream (Query Notification Header)

Why This Error Happens

This error occurs when the Query Notification request sent to SQL Server contains a malformed TDS header, typically caused by an outdated or mismatched SQL Server Native Client driver on the client application. It can also result from network packet corruption introduced by a misconfigured proxy, firewall, or load balancer sitting between the client and the SQL Server 2025 instance. In some cases, custom applications manually constructing TDS notification requests (via SqlDependency or Service Broker) send improperly formatted message bodies, triggering this validation failure on the server side.

Step-by-Step Resolution Guide

Step 1: Verify and Update Client Drivers

  • Confirm the application is using the latest Microsoft OLE DB Driver or ODBC Driver compatible with SQL Server 2025.
  • On Windows 11 / Windows Server 2025, check installed driver versions via Control Panel > Programs and Features.
  • Update outdated drivers using the official Microsoft Download Center package for “Microsoft ODBC Driver for SQL Server.”
  • Restart the application pool or service after updating to ensure the new driver binaries are loaded.

Step 2: Inspect Service Broker and Query Notification Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run the following to confirm Service Broker is enabled on the target database:
  SELECT is_broker_enabled FROM sys.databases WHERE name = 'YourDatabaseName';
  • If disabled, enable it with:
  ALTER DATABASE YourDatabaseName SET ENABLE_BROKER;
  • Validate that the SqlDependency.Start() call in application code is not being invoked multiple times with conflicting connection strings, as this can corrupt the notification queue.

Step 3: Capture and Analyze the TDS Stream

  • Use SQL Server Profiler or Extended Events to capture the raw TDS traffic at the time the error occurs.
  • Filter for Error 4010 events and inspect the packet payload for truncation or unexpected byte sequences.
  • Cross-reference the capture timestamp with any network hardware (firewall, load balancer) logs to rule out mid-stream packet tampering.

Step 4: Check for Network Layer Interference

  • On Windows Server 2025, open Windows Defender Firewall with Advanced Security and confirm no rules are fragmenting or inspecting TCP port 1433 traffic deeply.
  • Disable any third-party antivirus or deep packet inspection (DPI) proxy temporarily to test if the error persists.
  • If using a load balancer, ensure it is configured for raw TCP pass-through rather than TDS-aware inspection, since SQL Server 2025 TDS packets can be rejected if re-encapsulated incorrectly.

Step 5: Reinstall or Repair SQL Server Native Client Components

  • Navigate to Settings > Apps > Installed Apps on Windows 11, search for “SQL Server Native Client.”
  • Select Repair, or uninstall and reinstall using the latest setup package from Microsoft.
  • Re-test the Query Notification subscription after the repair completes.

Alternative or Verification Steps

  • Re-run the application’s notification subscription logic and confirm no Error 4010 entries appear in the SQL Server Error Log (Management > SQL Server Logs in SSMS) over a 24-hour monitoring window.
  • If the issue persists after driver updates, bypass Query Notifications temporarily by switching to a polling-based data refresh mechanism to isolate whether the root cause is TDS-specific or application logic-specific.

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

Microsoft SQL Server 2025 — Error 4008: “The data types varchar(max) … are incompatible”

Why This Error Happens

This error occurs when a T-SQL operation—typically a UNION, concatenation, comparison, or a built-in function like REPLICATE, CHARINDEX, or a CLR/XML operation—attempts to implicitly combine or compare varchar(max)/nvarchar(max)/varbinary(max) large object (LOB) data with an incompatible type, such as text, ntext, image, or a type with a mismatched collation. SQL Server’s query optimizer cannot find an implicit conversion path between the legacy deprecated LOB types (text/ntext/image) and the modern MAX types, so it rejects the operation rather than risk silent data truncation or corruption. This is almost always a schema design issue rather than a server configuration or permissions problem.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Query and Columns Causing the Conflict

  • Capture the failing statement from SQL Server Management Studio (SSMS) error output or the Windows Application Event Log (Event ID 4008, Source: MSSQLSERVER).
  • Run sp_help 'YourTableName' or query sys.columns joined with sys.types to check the data types of every column involved in the query:
SELECT c.name, t.name AS data_type, c.max_length
FROM sys.columns c
JOIN sys.types t ON c.user_type_id = t.user_type_id
WHERE c.object_id = OBJECT_ID('YourTableName');
  • Look specifically for legacy types: text, ntext, or image mixed with varchar(max), nvarchar(max), or varbinary(max).

Step 2: Convert Legacy LOB Columns to Modern MAX Types

  • Alter any columns still using deprecated types to their MAX equivalents:
ALTER TABLE dbo.YourTableName
ALTER COLUMN YourColumnName VARCHAR(MAX);
  • For ntext → use NVARCHAR(MAX); for image → use VARBINARY(MAX).
  • Note: tables with full-text indexes, replication, or indexed views may need those dependencies dropped before altering, then recreated afterward.

Step 3: Explicitly CAST or CONVERT in the Query Itself

  • If you cannot alter the underlying schema immediately (e.g., third-party vendor tables), wrap the offending column in an explicit conversion inside the query:
SELECT CAST(YourColumn AS VARCHAR(MAX)) FROM dbo.YourTableName
UNION
SELECT CAST(OtherColumn AS VARCHAR(MAX)) FROM dbo.OtherTable;
  • Ensure both sides of UNION, JOIN, or comparison operators use matching target types.

Step 4: Check and Align Collation Settings

  • Run SELECT DATABASEPROPERTYEX('YourDB', 'Collation'); and compare against SELECT collation_name FROM sys.columns WHERE object_id = OBJECT_ID('YourTableName');.
  • If collations differ between the two source tables/columns in a UNION or JOIN, add COLLATE DATABASE_DEFAULT to the conflicting column in your query.

Step 5: Update Client Drivers and Application Code

  • On Windows Server 2025 / Windows 11, confirm you are using the latest Microsoft OLE DB Driver for SQL Server or ODBC Driver 18+, since older drivers (pre-2012 era) mishandle MAX types.
  • Update connection strings and ORM mappings (Entity Framework, Dapper, etc.) to use MAX length definitions instead of legacy fixed-length LOB bindings.

Alternative or Verification Steps

  • Re-run the original query in SSMS after applying the ALTER TABLE or CAST fix — the 4008 error should no longer appear, and result sets should return without truncation warnings.
  • As a quick workaround while planning a full schema migration, use CONVERT(VARCHAR(MAX), column, 0) inline in reporting queries to bypass the type mismatch without altering production tables.

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

Troubleshooting Guide: TDS Protocol Stream Error 4009 in SQL Server 2025

Why This Error Happens

Error 4009 occurs when the SQL Server Database Engine receives a Tabular Data Stream (TDS) packet that is malformed, truncated, or out of sequence, causing the server to immediately terminate the connection. This is most commonly caused by network-layer corruption (faulty NICs, misconfigured routers, or MTU mismatches), an outdated or buggy client driver (such as an older ODBC or JDBC driver that doesn’t correctly format TDS headers), or interference from a security appliance/antivirus performing deep packet inspection on port 1433. In rarer cases, it stems from a corrupted installation of the SQL Server Native Client or a mismatch between the TDS version expected by the client versus the server.

Step-by-Step Resolution Guide

Step 1: Verify Network Integrity and Packet Handling

  • Run ping -f -l 1472 <SQLServerIP> from the client to check for fragmentation issues or packet loss.
  • Check Windows Server 2025 NIC settings in Device Manager; disable “TCP Checksum Offload” and “Large Send Offload (LSO)” temporarily to rule out NIC driver bugs.
  • Inspect any load balancers or firewalls sitting between the client and server for TCP reassembly issues on port 1433.

Step 2: Update or Reinstall Client Drivers

  • Navigate to the client machine and uninstall outdated connectivity components via Control Panel > Programs and Features (look for “Microsoft OLE DB Driver for SQL Server” or “ODBC Driver”).
  • Download and install the latest Microsoft OLE DB Driver 19+ or ODBC Driver 18+ compatible with SQL Server 2025 from the official Microsoft Download Center.
  • Restart the client application and re-attempt the connection to confirm the TDS handshake completes.

Step 3: Review SQL Server Network Configuration

  • Open SQL Server Configuration Manager on the Windows Server 2025 host.
  • Navigate to SQL Server Network Configuration > Protocols for MSSQLSERVER and ensure TCP/IP is enabled with correct Static Port (default 1433) under the IPAll section.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc or by running net stop MSSQLSERVER && net start MSSQLSERVER in an elevated Command Prompt.

Step 4: Exclude Security Software Interference

  • Open Windows Defender Firewall with Advanced Security and verify there is no deep packet inspection rule altering traffic on port 1433.
  • Temporarily disable third-party antivirus/endpoint protection software and attempt the connection again to isolate the cause.
  • If the connection succeeds, add an application-specific exclusion for sqlservr.exe and the SQL port in the antivirus configuration.

Step 5: Check SQL Server Error Log for Correlating Details

  • Open SQL Server Management Studio (SSMS) and navigate to Management > SQL Server Logs.
  • Look for entries immediately preceding the 4009 error, such as “A fatal error occurred while reading the input stream from the network,” which confirms a transport-layer issue.
  • Cross-reference the client IP and timestamp to narrow down whether the issue is isolated to a single machine or affects all incoming connections.

Alternative or Verification Steps

  • Use SQL Server Profiler or Extended Events to capture a trace during the next failed connection attempt; confirm no further 4009 errors appear after driver/network changes.
  • If the issue persists only for specific clients, bypass any intermediate proxy/VPN software and connect directly via the server’s IP address to confirm whether routing hardware is the root cause.

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

Troubleshooting Guide: SQL Server Error 4007

Why This Error Happens

Error 4007 occurs when an INSERT or UPDATE statement attempts to directly write a value into a column that SQL Server computes automatically, such as a computed column, an identity column, a timestamp/rowversion column, or a column backed by a view expression. This typically happens when application code or migration scripts reference a column by name without checking whether its definition was changed to a computed expression, or when a view’s underlying table schema was altered without updating the view. It can also surface after schema drift between development and production environments where a column was converted to a computed type.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Column

  • Review the full error message to capture the exact column name referenced in %.*ls.
  • Run the following query against the target table to check column properties:
SELECT name, is_computed, system_type_id 
FROM sys.columns 
WHERE object_id = OBJECT_ID('YourSchema.YourTable');
  • Confirm whether is_computed = 1 for the flagged column.

Step 2: Correct the INSERT/UPDATE Statement

  • Remove the computed column from the explicit column list in your INSERT INTO (...) statement.
  • If using an UPDATE statement, remove the SET ColumnName = value clause for that specific column.
  • For bulk insert operations via SSIS or bcp, update the mapping file to exclude the computed column, e.g.:
bcp YourDatabase.dbo.YourTable in data.txt -c -t, -S ServerName -T -k

Step 3: Validate View or Schema Definitions

  • If the error originates from a view, run sp_helptext 'ViewName' to inspect the underlying SELECT statement and confirm which columns are derived expressions (e.g., CAST, CASE, or string concatenation).
  • Update application ORM mappings (Entity Framework, Dapper, etc.) to mark the column as database-generated so it is excluded from write operations.
  • Restart the SQL Server service only if you modified computed column definitions via ALTER TABLE:
Restart-Service -Name 'MSSQLSERVER' -Force

Step 4: Rebuild Dependent Objects (If Schema Was Altered)

  • If the column was recently converted to computed, refresh dependent views and stored procedures using sp_refreshview or sp_refreshsqlmodule to ensure cached metadata matches the new schema.
  • Clear the plan cache for the affected database if stale execution plans persist:
DBCC FREEPROCCACHE;

Alternative or Verification Steps

  • Re-run the original INSERT/UPDATE statement in SQL Server Management Studio (SSMS) and confirm no Error 4007 is raised; check sys.columns again to ensure the computed flag matches expectations.
  • If the column must accept direct writes, consider removing the computed definition via ALTER TABLE ... DROP COLUMN and recreating it as a standard column, then repopulate data manually.

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

Troubleshooting Guide: SQL Server Error 4006

Why This Error Happens

Error 4006 occurs when a single DELETE statement targets a view or joined query that spans multiple underlying base tables, which the SQL Server engine cannot resolve into a single valid deletion operation. This typically happens when a view lacks an INSTEAD OF trigger to handle the multi-table logic, or when the view’s underlying query joins tables without a clear primary key relationship to isolate the delete target. Additionally, this can surface if a partitioned view is improperly configured, causing the engine to misidentify which partition or table owns the row being removed.

Step-by-Step Resolution Guide

Step 1: Identify the View or Query Causing the Conflict

  • Run sp_helptext 'YourViewName' in SQL Server Management Studio (SSMS) to inspect the view definition.
  • Check whether the FROM clause contains a JOIN between two or more base tables.
  • Confirm whether the view is partitioned by querying sys.views and sys.partitions for metadata flags.

Step 2: Create an INSTEAD OF Trigger to Handle Multi-Table Deletes

  • Navigate to SSMS, open a New Query window connected to the target database.
  • Write a trigger using the following template:
CREATE TRIGGER trg_InsteadOfDelete
ON YourViewName
INSTEAD OF DELETE
AS
BEGIN
    DELETE FROM TableA WHERE ID IN (SELECT ID FROM deleted);
    DELETE FROM TableB WHERE ID IN (SELECT ID FROM deleted);
END
  • Save and execute this script to bind the trigger to the problematic view.

Step 3: Split the Delete Operation into Separate Statements

  • Instead of running a single DELETE against the view, issue individual DELETE statements directly against each base table.
  • Use explicit WHERE clauses matching primary keys to ensure referential integrity is preserved.
  • If using an ORM (Entity Framework, Dapper), update the mapping configuration to disable cascading multi-table deletes through the view.

Step 4: Validate Permissions and Schema Bindings

  • Open SQL Server Configuration Manager (Windows Server 2025 / Windows 11 path: C:\Windows\System32\SQLServerManager16.msc).
  • Confirm the executing user has ALTER and CONTROL permissions on the view and underlying tables via sys.database_permissions.
  • Re-bind the view schema using sp_refreshview 'YourViewName' if columns were recently altered.

Alternative or Verification Steps

  • Re-run the original DELETE statement against the view; if Error 4006 no longer appears, the INSTEAD OF trigger is functioning correctly.
  • As an alternative, convert the view into a stored procedure (usp_DeleteFromMultipleTables) that explicitly handles deletion logic across both tables, bypassing the view-based restriction entirely.

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

Troubleshooting Guide: SQL Server Error 4005 — “Cannot Update Columns From More Than One Underlying Table”

Why This Error Happens

This error occurs when an UPDATE statement targets a view that joins two or more base tables, and the columns listed in the SET clause belong to more than one of those underlying tables. SQL Server’s query engine requires that a single UPDATE operation map to exactly one base table per call, since it cannot resolve ambiguous write paths across joined result sets. This is a design restriction of updatable views, not a bug, and typically surfaces when developers migrate reporting views into write-enabled application logic without accounting for view composition.

Step-by-Step Resolution Guide

Step 1: Identify the View Definition and Its Base Tables

  • Run sp_helptext 'YourViewName'; in SQL Server Management Studio (SSMS) to inspect the underlying JOIN structure.
  • Confirm which columns in your UPDATE statement map to which base table — Error 4005 almost always means columns span two tables in the FROM clause.
  • Check the Windows Event Viewer (Applications and Services Logs > MSSQLSERVER) to correlate the Error 4005 timestamp with the exact query submitted.

Step 2: Split the Update Into Separate Statements Per Table

  • Rewrite the single UPDATE into two (or more) discrete UPDATE statements, each targeting only one base table directly.
  • Example: instead of UPDATE vw_CustomerOrders SET CustomerName = @Name, OrderStatus = @Status, issue:
  • UPDATE Customers SET CustomerName = @Name WHERE CustomerID = @ID;
  • UPDATE Orders SET OrderStatus = @Status WHERE CustomerID = @ID;
  • Wrap both statements in a single BEGIN TRAN / COMMIT TRAN block to preserve atomicity if the application requires a transactional guarantee.

Step 3: Use INSTEAD OF Triggers for Persistent Multi-Table Views

  • If the application must keep issuing updates against the view (and cannot be refactored), create an INSTEAD OF UPDATE trigger on the view in SSMS.
  • Inside the trigger, parse the inserted and deleted pseudo-tables and route column updates to the correct base table programmatically.
  • Example skeleton:
  CREATE TRIGGER trg_UpdateView
  ON vw_CustomerOrders
  INSTEAD OF UPDATE
  AS
  BEGIN
      UPDATE c SET c.CustomerName = i.CustomerName
      FROM Customers c JOIN inserted i ON c.CustomerID = i.CustomerID;

      UPDATE o SET o.OrderStatus = i.OrderStatus
      FROM Orders o JOIN inserted i ON o.OrderID = i.OrderID;
  END

Step 4: Validate Application Connection and ORM Layer

  • If the error originates from an Entity Framework, Dapper, or other ORM-generated query, inspect the generated SQL via SQL Server Profiler or Extended Events on Windows Server 2025.
  • Ensure the ORM mapping targets individual tables (not the composite view) for write operations, adjusting entity mappings in the data context configuration file.

Alternative or Verification Steps

  • Re-run the original application transaction and confirm Error 4005 no longer appears in SSMS or the Windows Application Event Log.
  • As a quick validation, execute SELECT * FROM sys.triggers WHERE parent_id = OBJECT_ID('vw_CustomerOrders'); to confirm the INSTEAD OF trigger is active, then test an update against the view directly to ensure both base tables update correctly.

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

Troubleshooting Guide: SQL Server Error 4004 – Unicode Data Cannot Be Sent to Legacy Clients

Why This Error Happens

This error occurs because the client application is connecting to SQL Server 2025 using an outdated communication protocol, specifically DB-Library (DB-Lib) or ODBC driver versions 3.7 or earlier, neither of which support the transmission of Unicode (nchar, nvarchar, ntext) data types. Since SQL Server 2025 relies heavily on Unicode-only collations for internationalization, the legacy driver stack lacks the necessary API calls to decode the UCS-2/UTF-16 stream being sent by the server. Essentially, the client driver is too old to understand the modern data format required by the server instance.

Step-by-Step Resolution Guide

Step 1: Identify the Outdated Driver Component

  • Check the specific client tool generating the error (e.g., ISQL, older OLE DB applications, or legacy ODBC connections).
  • Navigate to Control Panel > Administrative Tools > ODBC Data Sources (64-bit) to check the version number of the currently configured DSN (Data Source Name).
  • Look for drivers named “SQL Server” (the legacy driver) rather than “ODBC Driver 17/18 for SQL Server.”

Step 2: Install the Modern Microsoft ODBC Driver

  • Download and install the Microsoft ODBC Driver 18 for SQL Server from the official Microsoft Download Center.
  • Run the installer on the Windows Server 2025 / Windows 11 machine with Administrator privileges.
  • Verify installation path integrity at C:\Windows\System32\msodbcsql18.dll.

Step 3: Reconfigure the Data Source Name (DSN)

  • Open the ODBC Data Source Administrator tool again.
  • Select the problematic DSN and click Configure.
  • Change the “Driver” dropdown from the legacy SQL Server driver to ODBC Driver 18 for SQL Server.
  • Re-enter the Server name and Authentication credentials to refresh the connection string.

Step 4: Update the Connection String in Application Code

  • If the error stems from a custom application rather than a GUI tool, locate the web.config or app.config file.
  • Update the Provider or Driver keyword in the connection string from {SQL Server} to {ODBC Driver 18 for SQL Server}.
  • Save the file and recycle the Application Pool (IIS) or restart the service to apply changes.

Step 5: Adjust Database Collation (If Driver Update is Not Feasible)

  • If legacy hardware restricts driver updates, open SQL Server Management Studio (SSMS).
  • Run a script to alter the specific column collation from a Unicode-only type (like Latin1_General_100_CI_AS_SC) to a standard Windows collation that supports non-Unicode clients.
  • Note: This is a workaround and may affect character support for special symbols.

Alternative or Verification Steps

  • Verification: Re-run the specific query or stored procedure that triggered Error 4004 via the updated connection; the data should now render correctly in the client’s grid/text view instead of throwing a conversion error.
  • Alternative: If updating ODBC is not possible, use the SQL Server Native Client (SNAC) or switch the client application to use ADO.NET, which fully supports Unicode data types natively.

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

Troubleshooting Guide: SQL Server Error 4002 – Incorrect TDS Protocol Stream

Why This Error Happens

This error typically occurs when the Tabular Data Stream (TDS) packets sent between the client and SQL Server 2025 are malformed, truncated, or interrupted mid-transmission. Common root causes include network instability or packet fragmentation, a mismatch between the client driver version and the server’s TDS protocol version, or interference from a firewall/antivirus application inspecting and altering the traffic. It can also result from an unstable or improperly closed connection pool on the application side.

Step-by-Step Resolution Guide

Step 1: Verify Network Stability and Packet Integrity

  • Run ping -t <ServerName> for an extended period to check for packet loss or latency spikes.
  • Check for network card driver issues in Windows 11/Server 2025 via Device Manager.
  • Disable TCP Chimney Offload and Receive Side Scaling (RSS) temporarily using netsh int tcp set global rss=disabled to rule out NIC offloading bugs.

Step 2: Update Client Drivers and Connection Strings

  • Ensure the client is using the latest Microsoft ODBC Driver or OLE DB Driver compatible with SQL Server 2025.
  • Check the application’s connection string for Encrypt and TrustServerCertificate settings, as TLS handshake failures can sometimes manifest as TDS stream errors.
  • Update the driver via the official Microsoft Download Center rather than relying on cached OS drivers.

Step 3: Adjust SQL Server Network Configuration

  • Open SQL Server Configuration Manager.
  • Navigate to SQL Server Network Configuration > Protocols for MSSQLSERVER.
  • Ensure “TCP/IP” is enabled and check the IPAll section to verify the correct Port (default 1433) is set without conflicting duplicate entries.
  • Restart the MSSQLSERVER service to apply changes.

Step 4: Check Firewall and Antivirus Packet Inspection

  • Temporarily disable Windows Defender Firewall or third-party antivirus software to see if the error persists.
  • If disabling resolves the issue, create a specific inbound/outbound rule for port 1433 to exclude SQL traffic from deep packet inspection.
  • Verify no Intrusion Detection System (IDS) is truncating large TDS packets sent during bulk data transfers.

Alternative or Verification Steps

  • Run a test query via SQL Server Management Studio (SSMS) immediately after applying the fixes to ensure the connection remains stable for at least 10 minutes without dropping.
  • If the error persists only during large data transfers, set the Network Packet Size property in the connection string to a lower value (e.g., 4096) to prevent oversized TDS packets from being rejected by intermediary network hardware.

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

Troubleshooting Guide: SQL Server Error 4001 — “Client Sends spresetconnection While There Is Still Pending Requests”

Why This Error Happens

This error occurs when the Tabular Data Stream (TDS) protocol detects that a client-side connection pool attempted to reset and reuse a connection via sp_reset_connection before the server finished processing an outstanding batch or result set from a prior command. This typically results from improper connection handling in application code, such as failing to fully read or cancel a DataReader before returning the connection to the pool, or from MARS (Multiple Active Result Sets) misconfiguration. It can also surface after driver mismatches between the client library (ODBC, OLE DB, or ADO.NET) and SQL Server 2025, which enforces stricter TDS state validation than previous versions.

Step-by-Step Resolution Guide

Step 1: Audit Application Connection Handling

  • Review application code for any SqlDataReader, SqlCommand, or similar objects that are not explicitly closed or disposed before the connection is returned to the pool.
  • Ensure every DataReader is wrapped in a using block or explicitly calls .Close()/.Dispose().
  • Check for asynchronous calls (ExecuteReaderAsync, ExecuteNonQueryAsync) that are not properly awaited, as this is the most common cause of orphaned pending requests.

Step 2: Enable and Verify MARS Configuration

  • Open the connection string used by the application and confirm whether MultipleActiveResultSets=True is required for your workload.
  • If MARS is enabled unintentionally, disable it unless the application explicitly handles multiple concurrent result sets, since MARS increases the risk of this race condition.
  • Update the connection string in web.config, app.config, or the relevant application settings file, for example:
    Server=myServer;Database=myDB;MultipleActiveResultSets=False;TrustServerCertificate=True;

Step 3: Update SQL Server Native Client / Driver Stack

  • On Windows Server 2025 / Windows 11, confirm the client is using the latest Microsoft ODBC Driver 18+ or Microsoft.Data.SqlClient (not the legacy System.Data.SqlClient).
  • Navigate to Control Panel > Programs > Programs and Features to check installed driver versions, or run:
    Get-OdbcDriver | Where-Object {$_.Name -like "*SQL Server*"}
  • Reinstall or update via the official Microsoft Download Center package matching SQL Server 2025 compatibility requirements.

Step 4: Adjust Connection Pooling Settings

  • In the application’s connection string, reduce Max Pool Size temporarily and set Pooling=True with a lower Connection Lifetime to force more frequent, cleaner connection resets.
  • For IIS-hosted applications, recycle the Application Pool via IIS Manager > Application Pools > Recycle after configuration changes to clear any stale pooled connections.

Step 5: Enable Extended Events Tracing for Confirmation

  • Open SQL Server Management Studio (SSMS) and navigate to Management > Extended Events > Sessions.
  • Create a new session capturing the sqlserver.error_reported event, filtered on Error Code 4001, to capture the exact query/session triggering the reset conflict.
  • Correlate the captured session_id with the application thread to pinpoint the exact faulty code path.

Alternative or Verification Steps

  • After applying fixes, monitor the SQL Server Error Log (Management > SQL Server Logs in SSMS) for 24–48 hours to confirm Error 4001 no longer appears.
  • If the issue persists, as a temporary workaround, disable connection pooling entirely (Pooling=False in the connection string) to isolate whether the pool itself is the root cause versus an application logic defect.

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

Troubleshooting Guide: SQL Server Error 3998 — “Uncommittable Transaction Detected at End of Batch”

Why This Error Happens

This error occurs when a transaction within a batch encounters an unhandled exception (such as a severity-level error, constraint violation, or explicit ROLLBACK mismatch) that leaves it in an uncommittable state, but the batch continues executing without checking XACT_STATE(). SQL Server 2025, by default, requires explicit handling of doomed transactions (XACT_STATE() = -1), and without a TRY...CATCH block that properly detects this state, the engine forcibly rolls back the transaction at the end of the batch. This is frequently caused by missing error-handling logic in stored procedures, triggers, or application-level T-SQL scripts rather than a server configuration fault.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Transaction Block

  • Review the stored procedure, trigger, or ad-hoc script referenced in the error log around Event ID 3998.
  • Check SQL Server Logs via SQL Server Management Studio (SSMS) > Management > SQL Server Logs or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG on Windows Server 2025.
  • Look for the specific batch or query that precedes the 3998 error to isolate the transaction scope.

Step 2: Implement Proper TRY…CATCH Error Handling

  • Wrap the transaction logic in a BEGIN TRY...END TRY and BEGIN CATCH...END CATCH block.
  • Inside the CATCH block, check the transaction state using:
  IF XACT_STATE() = -1
      ROLLBACK TRANSACTION;
  ELSE IF XACT_STATE() = 1
      COMMIT TRANSACTION;
  • Ensure every BEGIN TRANSACTION has a corresponding conditional COMMIT or ROLLBACK based on XACT_STATE(), not just @@ERROR.

Step 3: Adjust SET XACT_ABORT Configuration

  • Add SET XACT_ABORT ON; at the top of the affected stored procedure or script.
  • This forces SQL Server to automatically roll back the entire transaction on a runtime error, preventing orphaned uncommittable states.
  • Deploy the updated script via SSMS or Azure Data Studio and redeploy to any linked CI/CD pipelines targeting Windows Server 2025 instances.

Step 4: Validate Nested Transaction Logic

  • Check for nested BEGIN TRANSACTION calls using @@TRANCOUNT to ensure counts are balanced.
  • Avoid mixing SAVE TRANSACTION logic with full rollbacks without explicitly managing savepoints.
  • Refactor any legacy code using bare ROLLBACK without specifying the transaction name/savepoint if nested transactions are present.

Step 5: Restart the SQL Server Service (If Session State Persists)

  • Open Services.msc on Windows Server 2025 or Windows 11.
  • Locate SQL Server (MSSQLSERVER), right-click, and select Restart.
  • This clears any lingering session-level transaction states that may be causing repeated 3998 errors across connections.

Alternative or Verification Steps

  • Run the corrected stored procedure or script manually in SSMS and confirm no Error 3998 appears in the Messages tab, then verify @@TRANCOUNT returns to 0 after execution.
  • If the error persists under high concurrency, enable Extended Events (xEvents) with the error_reported event filtered to Error 3998 to capture the exact query and session causing the doomed transaction for deeper analysis.

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

Troubleshooting Guide: SQL Server Error 3999 – Failed to Flush Commit Table to Disk

Why This Error Happens

Error 3999 occurs when SQL Server’s In-Memory OLTP engine cannot persist the commit table (part of the transaction log/checkpoint process for memory-optimized filegroups) to disk. This is typically caused by underlying storage I/O failures, insufficient disk space on the volume hosting the memory-optimized filegroup, file system corruption, or the SQL Server service account lacking write permissions to the container files. It can also surface when the storage subsystem returns a hardware-level error (such as a stale file handle or disk timeout) that propagates up through the database engine.

Step-by-Step Resolution Guide

Step 1: Review the SQL Server Error Log for the Underlying Error Code

  • Open SQL Server Management Studio (SSMS) and navigate to Management > SQL Server Logs, or check the raw log file at C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • Locate the accompanying error number referenced in the message (error %d) — this is usually a Windows OS error code (e.g., 1450 “Insufficient system resources” or 112 “Disk full”).
  • Cross-reference the OS error code using net helpmsg <error_code> in an elevated Command Prompt to get a plain-language description.

Step 2: Verify Disk Space and Storage Health on the Memory-Optimized Filegroup Volume

  • Run the following query to identify the physical path of the memory-optimized filegroup container:
SELECT name, physical_name FROM sys.database_files WHERE type_desc = 'FILESTREAM';
  • Check free space on that volume using Get-PSDrive in PowerShell or File Explorer; ensure at least 15-20% free space is available.
  • Run chkdsk <drive>: /f /r during a maintenance window if disk corruption is suspected, and review Windows Event Viewer (System log) for Disk or NTFS warnings.

Step 3: Confirm Service Account Permissions on the Database Container Folder

  • Navigate to the folder housing the memory-optimized filegroup (commonly under D:\SQLData\<DBName>\<FilegroupName>).
  • Right-click the folder, select Properties > Security, and confirm the SQL Server service account (e.g., NT Service\MSSQLSERVER or a custom domain account) has Full Control.
  • If permissions are missing, grant them via icacls "D:\SQLData\<DBName>" /grant "NT SERVICE\MSSQLSERVER":(OI)(CI)F.

Step 4: Restart the SQL Server Service and Force a Manual Checkpoint

  • Restart the SQL Server service via services.msc or run Restart-Service MSSQLSERVER in an elevated PowerShell session.
  • Once the database is back online, manually force a checkpoint to retest the flush operation:
USE [YourDatabaseName];
CHECKPOINT;
  • Monitor the ERRORLOG immediately after to confirm Error 3999 does not reoccur.

Step 5: Rebuild or Restore the Affected Database if Corruption Persists

  • If the error persists after confirming disk space, permissions, and hardware health, run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS to check for underlying corruption.
  • If corruption is confirmed in the memory-optimized filegroup, restore the database from the last known good backup, as memory-optimized data/delta files generally cannot be repaired in place.

Alternative or Verification Steps

  • Verify the fix by inserting/updating a test row in a memory-optimized table and running CHECKPOINT again — confirm no new entries for Error 3999 appear in the ERRORLOG.
  • As an alternative diagnostic path, enable Extended Events with the sqlserver.error_reported event filtered on error number 3999 to capture the exact query and session context the next time the failure occurs.

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

Troubleshooting Guide: Error 3997 – MARS Batch Transaction Still Active at End of Batch

Why This Error Happens

This error occurs when Multiple Active Result Sets (MARS) is enabled on a connection, and an application explicitly begins a transaction (via BEGIN TRANSACTION) inside one batch but fails to commit or roll it back before that batch completes execution. SQL Server 2025 enforces strict transactional boundaries within MARS sessions, and leaving a transaction open across batch boundaries violates connection state integrity. As a safeguard against orphaned locks and inconsistent session state, SQL Server automatically rolls back the incomplete transaction and raises Error 3997.

Step-by-Step Resolution Guide

Step 1: Audit the Application’s Transaction Logic

  • Review the client code (ADO.NET, ODBC, or JDBC) for any BEGIN TRAN statements that are not matched with a corresponding COMMIT TRAN or ROLLBACK TRAN within the same batch execution.
  • Pay close attention to conditional branches (IF/ELSE) where an error path might skip the commit/rollback logic.
  • Search stored procedures for early RETURN statements that bypass transaction closure.

Step 2: Verify MARS Connection String Settings

  • Open the application’s configuration file (e.g., web.config, app.config, or connection string source).
  • Confirm MultipleActiveResultSets=True; is actually required for the workload; if not, disabling it forces sequential batch execution and prevents this specific error class.
  • If MARS is required, ensure the driver version supports SQL Server 2025 transactional semantics (update to the latest Microsoft.Data.SqlClient via NuGet or the ODBC Driver 18+ from the Microsoft Download Center).

Step 3: Implement Explicit TRY/CATCH with Transaction Handling

  • Wrap all transaction logic in T-SQL using BEGIN TRY ... END TRY BEGIN CATCH ... END CATCH.
  • Inside the CATCH block, add logic to check XACT_STATE():
  • If XACT_STATE() = -1, force a ROLLBACK TRANSACTION.
  • If XACT_STATE() = 1, issue a COMMIT or ROLLBACK as appropriate before exiting the batch.

Step 4: Enable Session-Level Tracing for Validation

  • Use SQL Server Profiler or Extended Events (XEvents) on the Windows Server 2025 instance to capture error_reported events filtered by Error Number 3997.
  • Correlate the captured batch_text with the specific client session to pinpoint which stored procedure or ad-hoc query is leaving the transaction open.

Alternative or Verification Steps

  • Verify the Fix: Run the application under load and query sys.dm_tran_active_transactions joined with sys.dm_tran_session_transactions to confirm no transactions remain in an uncommitted state after batch execution.
  • Alternative Solution: If refactoring the application code is not immediately feasible, set SET XACT_ABORT ON at the top of the stored procedure; this forces SQL Server to automatically roll back and terminate the batch immediately upon encountering a runtime error, preventing the transaction from persisting into an invalid state.

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

Troubleshooting Guide: SQL Server Error 3995 — “Unknown Transaction Isolation Level %d”

Why This Error Happens

This error occurs when SQL Server’s transaction manager receives an isolation level value that does not map to any of the recognized levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable, or Snapshot). It is typically caused by a corrupted connection string parameter, a driver mismatch between the client API (ODBC/OLE DB/ADO.NET) and SQL Server 2025, or a malformed bitmask value passed programmatically via SET TRANSACTION ISOLATION LEVEL. In rare cases, it can also surface due to memory corruption in the session context or an outdated client-side provider that does not recognize newer isolation level enumerations introduced in SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify the Client Driver and Provider Versions

  • Confirm you are using the latest Microsoft OLE DB Driver (MSOLEDBSQL19) or ODBC Driver 18+ compatible with SQL Server 2025.
  • Check installed driver version via Control Panel > Programs > Programs and Features on Windows Server 2025/Windows 11.
  • Update outdated drivers from the official Microsoft Download Center and restart the application.

Step 2: Inspect and Correct the Connection String / Application Code

  • Search application code or ORM configuration (Entity Framework, JDBC, etc.) for manually set isolation level integers instead of named constants.
  • Replace raw integer values with proper enumerations, for example in T-SQL:
  SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
  • In ADO.NET, ensure IsolationLevel enum values map correctly (avoid using IsolationLevel.Unspecified directly in BeginTransaction()).

Step 3: Validate SQL Server Configuration and Compatibility Level

  • Open SQL Server Management Studio (SSMS) and run:
  SELECT compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • Ensure compatibility level is set to 170 (SQL Server 2025) using:
  ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 170;
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER in PowerShell (Run as Administrator).

Step 4: Check for Corrupted System Files or Memory Issues

  • Run DBCC CHECKDB('YourDatabaseName') to rule out database corruption affecting session metadata.
  • On Windows Server 2025/Windows 11, run sfc /scannow in an elevated Command Prompt to repair corrupted system files that might affect the SQL Server service.

Alternative or Verification Steps

  • Re-run the failing transaction/query after driver and compatibility updates; confirm no Error 3995 appears in SQL Server Error Logs (EXEC sp_readerrorlog;).
  • If the issue persists, create a minimal repro script using SET TRANSACTION ISOLATION LEVEL SNAPSHOT; directly in SSMS to isolate whether the issue is client-side (driver/code) or server-side (corrupted metadata).

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

Troubleshooting Guide: Error 3996 — Snapshot Isolation Not Supported for Distributed Transaction

Why This Error Happens

This error occurs because SQL Server 2025 does not allow the SNAPSHOT or READ COMMITTED SNAPSHOT isolation level to be used once a transaction has been promoted to a distributed transaction via MSDTC (Microsoft Distributed Transaction Coordinator). It is typically triggered when a session with ALLOW_SNAPSHOT_ISOLATION or READ_COMMITTED_SNAPSHOT enabled on the database attempts to enlist in a linked server call, a BEGIN DISTRIBUTED TRANSACTION, or a cross-database transaction that spans multiple instances. The underlying engine architecture simply does not support versioning-based consistency models across a two-phase commit boundary.

Step-by-Step Resolution Guide

Step 1: Identify the Query or Procedure Triggering the Error

  • Check the application connection string or session settings for SET TRANSACTION ISOLATION LEVEL SNAPSHOT.
  • Review SQL Server logs and SSMS error output to locate the exact stored procedure or linked server call causing the promotion to a distributed transaction.
  • Use sys.dm_tran_active_transactions and sys.dm_tran_session_transactions to confirm if the transaction is distributed.

Step 2: Change the Isolation Level for the Affected Session

  • Explicitly set the isolation level before the transaction begins:
  SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
  BEGIN TRANSACTION;
  -- your distributed/linked server query here
  COMMIT TRANSACTION;
  • Avoid using READ_COMMITTED_SNAPSHOT or SNAPSHOT for any code path that touches linked servers or BEGIN DISTRIBUTED TRANSACTION.
  • If the database-level default is SNAPSHOT, override it at the session level rather than changing the database default globally.

Step 3: Isolate Distributed Transaction Logic from Snapshot-Dependent Code

  • Refactor stored procedures so that distributed transaction calls run in a separate batch/session that does not inherit SNAPSHOT isolation.
  • If using .NET or ODBC drivers, ensure Enlist=true connections default to READ COMMITTED unless explicitly required otherwise.
  • For linked server queries, confirm remote proc transaction promotion settings via:
  EXEC sp_configure 'remote proc trans', '1';
  RECONFIGURE;

Step 4: Verify MSDTC Configuration on Windows Server 2025 / Windows 11

  • Open Component Services (dcomcnfg.exe) → Computers → My Computer → Distributed Transaction Coordinator → Local DTC.
  • Confirm Network DTC Access is enabled and that “Allow Inbound/Outbound” transactions are permitted if the query spans remote instances.
  • Restart the MSDTC service after any configuration change:
  Restart-Service MSDTC

Alternative or Verification Steps

  • Re-run the failing transaction after setting isolation level to READ COMMITTED or SERIALIZABLE; confirm no Error 3996 appears in SQL Server logs or sys.messages.
  • If the issue persists, avoid distributed transactions altogether by using application-level two-phase logic (e.g., saga pattern) or linked server queries wrapped in local transactions only.

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

Troubleshooting Guide: SQL Server Error 3994 — “User Defined Routine” Failure

Why This Error Happens

Error 3994 typically occurs when a user-defined routine (function, stored procedure, or CLR assembly) encounters an unhandled exception during execution, often due to corrupted or outdated CLR assembly bindings within SQL Server 2025. This can also stem from insufficient permissions on the TRUSTWORTHY database property or missing SQL Server service account access to the referenced assembly files. In some cases, the issue arises from version mismatches between the .NET runtime used by Windows Server 2025 and the CLR integration expected by SQL Server.

Step-by-Step Resolution Guide

Step 1: Verify CLR Integration Status

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run SELECT * FROM sys.configurations WHERE name = 'clr enabled'; to confirm CLR is active.
  • If disabled, enable it using sp_configure 'clr enabled', 1; RECONFIGURE;

Step 2: Check Assembly and Permission Integrity

  • Navigate to Object Explorer > Databases > [YourDB] > Programmability > Assemblies.
  • Right-click the relevant assembly and select Script Assembly as > DROP and CREATE to refresh its binary definition.
  • Ensure the database has TRUSTWORTHY set correctly: ALTER DATABASE [YourDB] SET TRUSTWORTHY ON; (only if the source is verified safe).
  • Confirm the SQL Server service account has Read & Execute permissions on the assembly’s source .dll path, typically under C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\.

Step 3: Update and Restart SQL Server Services

  • Open Services.msc on Windows Server 2025 and locate SQL Server (MSSQLSERVER).
  • Restart the service to clear any cached execution plans tied to the faulty routine.
  • Apply the latest Cumulative Update (CU) for SQL Server 2025 via SQL Server Setup > Maintenance Wizard to patch known CLR execution bugs.

Alternative or Verification Steps

  • Re-run the original query or stored procedure that triggered Error 3994 and check the SQL Server Error Log (via EXEC sp_readerrorlog;) to confirm no further CLR-related exceptions appear.
  • If the error persists, consider recompiling the routine entirely using sp_recompile '[RoutineName]'; or rebuilding the assembly from source code to rule out binary corruption.

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

Why This Error Happens

Error 3993 occurs when a trigger, user-defined function, or stored procedure begins an explicit transaction (via BEGIN TRAN) but the routine terminates—either by completing execution or hitting an unhandled exception—before issuing a matching COMMIT or ROLLBACK. SQL Server 2025 enforces strict transaction nesting rules, so any mismatch between @@TRANCOUNT at the start and end of the routine triggers this error to prevent orphaned transactions. This is almost always a code-level issue rather than a server configuration problem, often surfacing after a migration to SQL Server 2025 due to its updated transaction validation engine.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Routine

  • Check the SQL Server error log (via SSMS or xp_readerrorlog) for the exact stored procedure, trigger, or function name referenced in the 3993 message.
  • Use DBCC INPUTBUFFER(<session_id>) or Extended Events to capture the exact statement that caused the failure in real time.
  • Note the @@TRANCOUNT value logged alongside the error for context on how deep the nesting went.

Step 2: Audit the Transaction Logic in the Code

  • Open the routine in SSMS or Azure Data Studio and search for BEGIN TRAN, COMMIT, and ROLLBACK keywords.
  • Verify every code branch (including CATCH blocks, early RETURN statements, and IF/ELSE conditions) has a corresponding COMMIT or ROLLBACK for every BEGIN TRAN.
  • Pay special attention to nested triggers or procedures calling other procedures that also manage transactions—this is the most common cause of mismatched counts.

Step 3: Implement TRY…CATCH with Proper Rollback Handling

  • Wrap the transactional logic in a BEGIN TRY...END TRY / BEGIN CATCH...END CATCH block.
  • Inside the CATCH block, add:
IF @@TRANCOUNT > 0
    ROLLBACK TRANSACTION;
  • Ensure SET XACT_ABORT ON; is declared at the top of the procedure/trigger to force automatic rollback on severe errors, reducing the chance of a dangling transaction state.

Step 4: Test in an Isolated Environment

  • Deploy the corrected routine to a Windows Server 2025 test instance or a local Windows 11 development environment with SQL Server 2025 installed.
  • Run the original failing transaction/workload against the patched code and monitor @@TRANCOUNT before and after execution using PRINT or SELECT @@TRANCOUNT debug statements.

Step 5: Deploy and Monitor in Production

  • Push the validated script to production during a low-traffic maintenance window.
  • Enable SQL Server Agent alerts for Error 3993 (Severity 16) so any recurrence is immediately flagged via email or SCOM notification.

Alternative or Verification Steps

  • Run DBCC OPENTRAN on the affected database immediately after reproducing the workload to confirm no transaction is left open.
  • If the error persists despite code fixes, temporarily enable Trace Flag 3609 on a test instance to get verbose transaction-state logging, which helps pinpoint exactly where the trancount drifts.

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

Troubleshooting Guide: SQL Server Error 3992 – “Transaction Count Has Been Changed Inside of User Defined Routine”

Why This Error Happens

This error occurs when a stored procedure, function, or trigger commits or rolls back a transaction that it did not explicitly begin, causing a mismatch between the @@TRANCOUNT value when the routine started versus when it exited. SQL Server 2025 enforces strict transaction nesting rules, and any unbalanced BEGIN TRAN/COMMIT/ROLLBACK logic inside a user-defined routine will trigger this error to prevent silent data integrity issues. This is almost always a code-level defect rather than a server configuration or permissions problem, often introduced after a migration, stored procedure update, or ORM-generated batch script.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Routine

  • Check the SQL Server error log or Windows Event Viewer (Applications and Services Logs > MSSQLSERVER) for the exact procedure name referenced alongside Error 3992.
  • Run the following to capture the current transaction count context:
SELECT @@TRANCOUNT AS CurrentTranCount;
  • Use SQL Server Profiler or Extended Events (sqlserver.error_reported) filtered on Error Number = 3992 to capture the exact batch and session that triggered it.

Step 2: Audit the Transaction Logic in the Procedure

  • Open the procedure definition using SSMS or Azure Data Studio:
EXEC sp_helptext 'YourSchema.YourProcedureName';
  • Look specifically for unmatched COMMIT TRAN, ROLLBACK TRAN, or COMMIT WORK statements, especially inside TRY...CATCH blocks or conditional branches (IF/ELSE) where one path commits/rolls back and another does not.
  • Confirm that every BEGIN TRANSACTION has a corresponding COMMIT or ROLLBACK within the same scope, and that nested calls do not issue a blanket ROLLBACK that wipes out the caller’s transaction unexpectedly.

Step 3: Standardize Transaction Handling with SAVE TRAN or TRY/CATCH Pattern

  • Rewrite the routine using a consistent pattern that tracks the starting @@TRANCOUNT:
DECLARE @TranCountStart INT = @@TRANCOUNT;
BEGIN TRY
    IF @TranCountStart = 0
        BEGIN TRANSACTION;
    -- business logic here
    IF @TranCountStart = 0
        COMMIT TRANSACTION;
END TRY
BEGIN CATCH
    IF @@TRANCOUNT > @TranCountStart
        ROLLBACK TRANSACTION;
    THROW;
END CATCH;
  • Deploy the corrected procedure using ALTER PROCEDURE and test it in a staging environment before pushing to production on Windows Server 2025.

Step 4: Validate XACT_ABORT and Nested Trigger Settings

  • Ensure SET XACT_ABORT ON; is declared at the top of the routine to force automatic rollback on error, preventing orphaned transactions.
  • Check sys.configurations for nested triggers and remote proc trans settings, as these can compound transaction count mismatches in multi-server or linked-server calls:
EXEC sp_configure 'nested triggers';

Alternative or Verification Steps

  • Re-execute the original failing batch or application workflow and monitor @@TRANCOUNT before and after the call using PRINT @@TRANCOUNT; to confirm it returns to the expected baseline (usually 0 at the outermost scope).
  • If the error persists in a third-party or vendor-supplied procedure that cannot be modified, wrap the call in your own transaction-safe wrapper procedure that isolates the external call using SAVE TRANSACTION savepoints instead of full BEGIN TRAN.

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

Why This Error Happens

Error 3991 occurs when a COMMIT or ROLLBACK statement is executed inside a stored procedure, trigger, or user-defined function that terminates the outer transaction context that was already active before the routine was called. SQL Server 2025 strictly enforces transaction nesting rules, and modifying the parent transaction’s state from within a nested routine is not permitted. This is typically caused by poorly designed error-handling logic (e.g., a TRY...CATCH block issuing a blind ROLLBACK without checking @@TRANCOUNT) or legacy code migrated from older SQL Server versions that didn’t enforce this as strictly.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Routine

  • Check the full error message text — it names the specific procedure, trigger, or function (e.g., “…inside of it, which is not allowed” will reference the object name).
  • Open SQL Server Management Studio (SSMS) and script out the object using sp_helptext 'YourProcName' or right-click → Modify.
  • Look specifically for COMMIT TRANSACTION, ROLLBACK TRANSACTION, or COMMIT WORK statements inside TRY...CATCH blocks.

Step 2: Fix the Transaction Logic

  • Wrap rollback logic with a check against XACT_STATE() instead of blindly calling ROLLBACK:
IF XACT_STATE() <> 0
    ROLLBACK TRANSACTION;
  • Avoid starting a new BEGIN TRANSACTION inside a routine if one is already active; use SAVE TRANSACTION (savepoints) instead for nested logic.
  • Ensure every BEGIN TRY has a matching CATCH block that does not terminate a transaction it did not start.

Step 3: Validate Transaction Count Before Exit

  • Add a check at the end of the routine to confirm @@TRANCOUNT matches the value captured on entry:
DECLARE @TranCountStart INT = @@TRANCOUNT;
-- routine logic here
IF @@TRANCOUNT <> @TranCountStart
    RAISERROR('Transaction count mismatch detected', 16, 1);
  • Deploy the corrected object using ALTER PROCEDURE or ALTER FUNCTION via SSMS or sqlcmd.

Step 4: Clear Cached Execution Plans

  • After altering the object, run DBCC FREEPROCCACHE (or targeted sp_recompile 'YourProcName') to ensure Windows Server 2025’s SQL Server instance isn’t executing a stale, cached version of the faulty logic.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER if the issue persists after recompilation.

Alternative or Verification Steps

  • Re-run the original query or application transaction that triggered Error 3991 and confirm it completes without raising the exception; check SQL Server Logs (Management → SQL Server Logs in SSMS) for recurrence.
  • If the error persists, enable Extended Events (xp_trace or the “Errors and Warnings” template) to capture the exact call stack and transaction state at the moment of failure for deeper root-cause analysis.

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

Troubleshooting Guide: Error 3990 – “Transaction Is Not Allowed to Commit Inside of a User Defined Routine”

Why This Error Happens

This error occurs because SQL Server 2025 does not permit a stored procedure, trigger, or user-defined function to commit or roll back a transaction that it did not explicitly begin itself. Typically, this happens when a nested stored procedure calls COMMIT TRANSACTION or ROLLBACK TRANSACTION without matching the exact transaction count (@@TRANCOUNT) at the scope in which it was opened. It can also surface when a trigger attempts to manage transaction state directly, which violates SQL Server’s strict transaction nesting rules.

Step-by-Step Resolution Guide

Step 1: Audit the Transaction Nesting in Your Code

  • Open the stored procedure or routine referenced in the error log and locate every BEGIN TRAN, COMMIT, and ROLLBACK statement.
  • Check the value of @@TRANCOUNT before and after each block to ensure the routine isn’t closing a transaction it did not open.
  • Run the following diagnostic query to capture the current transaction state during execution:
  SELECT @@TRANCOUNT AS CurrentTranCount;

Step 2: Refactor the Routine to Use SAVEPOINTS Instead of Direct Commits

  • Replace internal COMMIT TRANSACTION calls within nested procedures with SAVE TRANSACTION (savepoints) so only the outermost caller controls the final commit.
  • Update the routine logic as follows:
  BEGIN TRY
      SAVE TRANSACTION MySavePoint;
      -- business logic here
  END TRY
  BEGIN CATCH
      ROLLBACK TRANSACTION MySavePoint;
  END CATCH
  • Ensure the outermost calling script (not the inner procedure) is solely responsible for the final COMMIT.

Step 3: Validate Trigger Logic (If Applicable)

  • If the error originates from an INSTEAD OF or AFTER trigger, remove any explicit COMMIT or ROLLBACK statements inside the trigger body.
  • Triggers should rely on RAISERROR or THROW to signal failure, allowing the calling transaction scope to decide whether to roll back.
  • Re-deploy the modified trigger using SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your Windows Server 2025 instance.

Step 4: Check XACT_ABORT and Transaction Isolation Settings

  • Verify that SET XACT_ABORT ON; is declared at the top of the routine to ensure automatic rollback on runtime errors, preventing orphaned transaction states.
  • Confirm the connection string used by the application (especially if running on Windows 11 client machines) isn’t manually overriding transaction isolation levels mid-session.

Alternative or Verification Steps

  • To verify the fix, execute the stored procedure manually in SSMS while monitoring SELECT @@TRANCOUNT; before and after execution—it should return to 0 after the outer transaction commits successfully.
  • If the error persists, use SQL Server Profiler or Extended Events to trace the exact nesting level where the COMMIT is being rejected, as this often reveals a secondary hidden procedure call causing the conflict.

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

Troubleshooting Guide: SQL Server Error 3989 — “New request is not allowed to start because it should come with valid transaction descriptor”

Why This Error Happens

This error occurs when a distributed or marked transaction becomes orphaned or invalid on the SQL Server session, typically because the client application attempted to reuse a transaction descriptor after the original transaction was aborted, timed out, or the connection pool returned a stale enlisted transaction. It frequently surfaces after MSDTC (Microsoft Distributed Transaction Coordinator) communication failures, abrupt network interruptions during a distributed transaction, or when connection pooling hands back a connection still bound to a dead transaction context. In some cases, corrupted or mismatched MSDTC configuration between the application server and SQL Server 2025 instance on Windows Server 2025 triggers this behavior.

Step-by-Step Resolution Guide

Step 1: Verify and Restart MSDTC Service

  • Open Services.msc on both the SQL Server host and the application server.
  • Locate Distributed Transaction Coordinator, right-click, and select Restart.
  • Confirm the service is set to Automatic startup type to prevent recurrence after reboot.
  • Run msdtc -resetlog from an elevated Command Prompt if the service fails to start cleanly.

Step 2: Reconfigure MSDTC Security Settings

  • Open Component Services (dcomcnfg.exe) → Component Services > Computers > My Computer > Distributed Transaction Coordinator > Local DTC.
  • Right-click Local DTC, choose Properties, and go to the Security tab.
  • Enable Network DTC Access, Allow Inbound, Allow Outbound, and set Transaction Manager Communication to No Authentication Required (or Mutual Authentication if domain policy requires it).
  • Apply changes and restart the MSDTC service when prompted.

Step 3: Audit Application Connection Pooling and Transaction Handling

  • Review application code for any SqlConnection or ADO.NET objects that reuse a TransactionScope after it has been disposed or timed out.
  • Ensure Enlist=true is correctly set in the connection string only when distributed transactions are intended.
  • Reduce Connection Lifetime in the connection string to force pooled connections to recycle more frequently, preventing stale transaction descriptors from being reused.

Step 4: Update SQL Server 2025 Cumulative Updates

  • Check SQL Server Configuration Manager for the current build version.
  • Download and apply the latest Cumulative Update (CU) from Microsoft, as transaction descriptor handling bugs are periodically patched.
  • Reboot the server after installation and confirm via SELECT @@VERSION; in SQL Server Management Studio (SSMS).

Step 5: Review SQL Server Error Logs and Extended Events

  • Open SSMS and navigate to Management > SQL Server Logs.
  • Search for correlating Error 3989 entries alongside any MSDTC or network-related warnings.
  • Set up an Extended Events session tracking sqlserver.error_reported filtered on Error 3989 to capture the exact query/session triggering the fault for deeper diagnosis.

Alternative or Verification Steps

  • Verify the fix by running a test distributed transaction (e.g., BEGIN DISTRIBUTED TRANSACTION) from both an SSMS query window and the application layer, confirming it commits/rolls back without triggering Error 3989.
  • If the issue persists, as a workaround, disable connection pooling temporarily (Pooling=false in the connection string) to isolate whether the descriptor corruption originates from pooled connection reuse versus a genuine MSDTC/network failure.

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

Troubleshooting Guide: SQL Server Error 3988

Why This Error Happens

Error 3988 occurs when an application attempts to open a new transaction (via BEGIN TRANSACTION or an API call) while another thread or batch within the same session (SPID) still has an active operation running, such as an unfinished SELECT or an asynchronous command. This is common in applications using Multiple Active Result Sets (MARS) incorrectly, or when connection pooling reuses a session before the previous transaction thread has fully released control. It can also occur if a client-side timeout forces a new command onto a connection string that the server still considers “busy” with a prior thread.

Step-by-Step Resolution Guide

Step 1: Verify MARS Configuration in the Connection String

  • Check the application’s connection string (web.config, appsettings.json, or ODBC DSN) for the MultipleActiveResultSets parameter.
  • If using ADO.NET, ensure it is explicitly set: MultipleActiveResultSets=True;
  • If the driver does not support MARS correctly, disable it and rely on standard sequential processing instead.

Step 2: Isolate the Session Using Activity Monitor

  • Open SQL Server Management Studio (SSMS) and connect to the Windows Server 2025 instance.
  • Navigate to Activity Monitor > Processes and filter by the specific SPID reporting the error.
  • Run the following query to identify blocking threads within the same session:
SELECT session_id, status, command, blocking_session_id 
FROM sys.dm_exec_requests 
WHERE session_id = <Your_SPID>;

Step 3: Refactor Application Threading Logic

  • Audit the application code (C#, Java, or Python) for instances where a connection object is shared across multiple threads simultaneously.
  • Ensure that SqlConnection objects are not static or singleton instances shared by concurrent processes; implement a connection pool per-thread instead.
  • Add explicit SqlCommand.Cancel() calls before attempting to open a new transaction on a recycled connection object.

Step 4: Update SQL Server Native Client/Driver

  • Navigate to the Microsoft Download Center and ensure you are running the latest ODBC Driver 18 or newer, compatible with SQL Server 2025.
  • Uninstall legacy “SQL Server Native Client” drivers via Control Panel > Programs and Features on the Windows 11/Server 2025 machine, as these often mismanage thread handles.
  • Restart the SQL Server (MSSQLSERVER) service to ensure the new driver handshake takes effect:
Restart-Service -Name 'MSSQLSERVER' -Force

Alternative or Verification Steps

  • Verification: Run a load test using SQLQueryStress or a custom script to simulate concurrent transactions; confirm Error 3988 no longer appears in the SQL Server Error Log (Management > SQL Server Logs).
  • Alternative: If the error persists under MARS, switch the application logic to explicit TransactionScope management in .NET, ensuring the scope is disposed of immediately after the thread completes its read/write operation.

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

Troubleshooting Guide: Error 3987 — SNAPSHOT ISOLATION is Always Enabled in This Database

Why This Error Happens

This error occurs because the database already has ALLOW_SNAPSHOT_ISOLATION set to ON, which is a persistent, database-level setting that does not reset between sessions or connections. When an attempt is made to re-run the ALTER DATABASE command to enable snapshot isolation on a database where it is already active, SQL Server raises Error 3987 instead of silently ignoring the redundant command. This is typically caused by a misunderstanding of the current database state, an automated deployment or migration script running without a pre-check, or a conflict between multiple scripts/tools attempting to configure isolation levels simultaneously.

Step-by-Step Resolution Guide

Step 1: Verify the Current Snapshot Isolation State

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and connect to the target instance.
  • Run the following query to check the current state of the database:
  SELECT name, snapshot_isolation_state, snapshot_isolation_state_desc 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • A result of 1 or ON confirms that snapshot isolation is already active and no further action is needed to “enable” it.

Step 2: Review and Correct the Deployment Script

  • Locate the source of the command, typically found in a .sql deployment file, a DACPAC post-deployment script, or a DevOps pipeline (e.g., Azure DevOps YAML or Jenkinsfile).
  • Modify the script to include a conditional check before executing the ALTER DATABASE command to prevent the error from halting the pipeline:
  IF EXISTS (SELECT 1 FROM sys.databases WHERE name = 'YourDatabaseName' AND snapshot_isolation_state = 0)
  BEGIN
      ALTER DATABASE YourDatabaseName SET ALLOW_SNAPSHOT_ISOLATION ON;
  END
  • Save the script and ensure it is updated in the source control repository (e.g., Git) to prevent future occurrences.

Step 3: Check for Conflicting Automation Tools

  • Audit SQL Server Agent Jobs via SSMS under SQL Server Agent > Jobs to ensure no other scheduled job is attempting to toggle this setting.
  • Check for third-party monitoring tools or ORM frameworks (like Entity Framework migrations) that might be forcing this setting on every application startup.
  • Disable or update the redundant job/script to remove the duplicate ALTER DATABASE call.

Step 4: Restart the Target Service (If State Appears Stuck)

  • If the sys.databases view shows inconsistent data compared to the actual behavior, restart the SQL Server service to clear the cache.
  • Open Command Prompt as Administrator on Windows Server 2025 and run:
  net stop MSSQLSERVER
  net start MSSQLSERVER
  • Re-verify the state using the query from Step 1 immediately after the service restarts.

Alternative or Verification Steps

  • Verification: Run a test transaction using SET TRANSACTION ISOLATION LEVEL SNAPSHOT; followed by a SELECT statement to ensure the database accepts the isolation level without throwing errors.
  • Alternative: If the setting needs to be toggled (e.g., for maintenance), first disable it using ALTER DATABASE YourDatabaseName SET ALLOW_SNAPSHOT_ISOLATION OFF;, ensure no active snapshot transactions are running, and then re-enable it successfully without triggering Error 3987.

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

Why This Error Happens

Error 3986 occurs when the internal global transaction timestamp counter used by SQL Server’s In-Memory OLTP (Hekaton) engine reaches its maximum allowable value. This counter is a lightweight, monotonically increasing value used to order transactions across memory-optimized tables, and once exhausted, SQL Server cannot generate new timestamps for incoming transactions. This typically happens on servers with extremely high transaction volumes against memory-optimized objects that have been running for a very long time without a restart, or due to a bug in older builds that increments the counter more aggressively than expected.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of the Issue

  • Check the SQL Server Error Log (Management > SQL Server Logs in SSMS, or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for repeated instances of Error 3986.
  • Identify whether the affected database(s) use memory-optimized tables (In-Memory OLTP) by running:
SELECT name, is_memory_optimized_elevate_to_snapshot_on 
FROM sys.databases;
  • Note the exact time of failure to correlate with transaction volume spikes.

Step 2: Perform a Controlled Restart of the SQL Server Service

  • Open Services.msc on Windows Server 2025 / Windows 11 and locate SQL Server (MSSQLSERVER) or the named instance.
  • Right-click and select Restart, or run from an elevated PowerShell prompt:
Restart-Service -Name 'MSSQLSERVER' -Force
  • This resets the in-memory transaction timestamp counter, which is the only way to recover from this specific error once it occurs.

Step 3: Apply the Latest Cumulative Update (CU) for SQL Server 2025

  • Navigate to the Microsoft Update Catalog and download the latest Cumulative Update for SQL Server 2025.
  • Install the patch using the setup wizard or silently via:
Setup.exe /Action=Patch /IAcceptSQLServerLicenseTerms /Quiet /InstanceName=MSSQLSERVER
  • This CU includes fixes to the timestamp allocation logic that reduce the frequency of counter exhaustion under heavy In-Memory OLTP workloads.

Step 4: Schedule Proactive Maintenance Restarts

  • Configure a maintenance plan or Task Scheduler job to restart the SQL Server service during a low-traffic window (e.g., weekly) to preemptively reset the timestamp counter.
  • Use SQL Server Agent to create a job with a CmdExec step:
net stop MSSQLSERVER && net start MSSQLSERVER
  • Document this as a known mitigation until the underlying workload is optimized or reduced.

Alternative or Verification Steps

  • After restarting, verify the fix by monitoring the Error Log for 24–48 hours to confirm Error 3986 does not recur, and check sys.dm_db_xtp_transaction_stats for healthy timestamp generation.
  • If the error reoccurs frequently, consider reviewing application logic to reduce unnecessary transaction churn on memory-optimized tables, or open a support case with Microsoft to evaluate a hotfix specific to your build number.

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

Troubleshooting Guide: SQL Server Error 3985 – Transaction Context Change Failure

Why This Error Happens

Error 3985 typically occurs when SQL Server 2025 cannot allocate sufficient memory to switch transaction contexts, often during distributed transactions, linked server queries, or when using sp_getbindtoken and sp_bindsession. This is frequently triggered by memory pressure from the Buffer Pool being set too high relative to available system RAM, or by other processes on Windows Server 2025 competing for physical memory. In some cases, this error is a symptom of memory fragmentation within the SQL Server process rather than true system-wide memory exhaustion.

Step-by-Step Resolution Guide

Step 1: Verify Current Memory Configuration

  • Open SQL Server Management Studio (SSMS) and run: EXEC sp_configure 'max server memory'
  • Check if the value is set too close to the total physical RAM (leave at least 4-8 GB for the OS on Windows Server 2025).
  • Review current usage via: SELECT * FROM sys.dm_os_process_memory

Step 2: Adjust Max Server Memory Setting

  • Run the following to reconfigure, replacing <value> with an appropriate MB figure (e.g., leave 20% of RAM for the OS):
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'max server memory', <value>;
RECONFIGURE;
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER for changes to take full effect.

Step 3: Check for Memory Leaks in Other Processes

  • Open Task Manager or Performance Monitor (perfmon.exe) on Windows Server 2025.
  • Monitor the counter Memory\Available MBytes; if it consistently drops below 500 MB, identify and close competing processes (e.g., antivirus scans, backup agents).
  • Check Windows Event Viewer under Applications and Services Logs > MSSQLSERVER for recurring Out-Of-Memory (OOM) warnings correlating with Error 3985.

Step 4: Review Linked Server and Distributed Transaction Settings

  • If the error occurs during cross-database or linked server queries, verify the MSDTC (Distributed Transaction Coordinator) service is running: services.msc → check “Distributed Transaction Coordinator”.
  • Ensure linked server memory-intensive queries are optimized or broken into smaller batches to reduce simultaneous context switches.

Step 5: Apply Latest SQL Server 2025 Cumulative Update

  • Navigate to the Microsoft Update Catalog and download the latest Cumulative Update (CU) for SQL Server 2025.
  • Install the update and reboot the server, as this error has known fixes related to memory handling in earlier builds.

Alternative or Verification Steps

  • To verify the fix, re-run the failing transaction/query and monitor sys.dm_os_memory_clerks to confirm memory allocation stabilizes without triggering Error 3985.
  • If the issue persists, consider adding physical RAM to the Windows Server 2025 host or migrating to a dedicated SQL Server instance with reduced concurrent workloads.

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

Troubleshooting Guide: Error 3984 – Cannot Acquire Database Lock During Transaction Change

Why This Error Happens

Error 3984 typically occurs when the database engine is unable to obtain the necessary lock on a resource (row, page, or table) because the transaction log is unable to mark a log sequence number (LSN) as part of an active checkpoint or recovery operation. This is most commonly caused by a corrupted or inconsistent transaction log file, insufficient memory allocated to the Lock Manager, or a long-running blocking transaction that has exhausted available lock resources. In some cases, this error surfaces after an improper shutdown or storage-level I/O interruption on Windows Server 2025 that leaves the database in a transitional state.

Step-by-Step Resolution Guide

Step 1: Verify Database and Transaction Log Integrity

  • Open SQL Server Management Studio (SSMS) and run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORS;
  • Check the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for related corruption warnings.
  • If corruption is found, restore from the latest clean backup before proceeding further.

Step 2: Identify and Terminate Blocking Transactions

  • Run the following query to identify blocking sessions: SELECT * FROM sys.dm_tran_locks WHERE request_status = 'WAIT';
  • Cross-reference blocking session IDs using EXEC sp_who2 'active';
  • If a session is confirmed as an orphaned or long-running blocker, terminate it using KILL <session_id>;

Step 3: Increase Lock Resources and Adjust Memory Configuration

  • Open SSMS, right-click the server instance, and go to Properties > Memory.
  • Ensure “Maximum server memory” is not set too restrictively (recommended: leave at least 20% of system RAM for the OS on Windows Server 2025).
  • If using locked pages, verify the SQL Server service account has the “Lock Pages in Memory” policy enabled via secpol.msc under Local Policies > User Rights Assignment.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER for changes to take effect.

Step 4: Rebuild or Repair the Transaction Log (If Required)

  • If the log file is flagged as suspect, set the database to emergency mode: ALTER DATABASE YourDatabaseName SET EMERGENCY;
  • Run ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE; followed by DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);
  • Revert to multi-user mode: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Alternative or Verification Steps

  • Re-run the original transaction that triggered Error 3984 and monitor sys.dm_os_wait_stats for LCK_M_* wait types to confirm locks are being released properly.
  • If the issue persists, failover to a secondary replica (if using Always On Availability Groups) and perform a full consistency check on the primary node before reintroducing it to the cluster.

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

Troubleshooting Guide: SQL Server Error 3982

Why This Error Happens

Error 3982 occurs when a session attempts to start a new local or distributed transaction while an existing transaction—managed either by the Microsoft Distributed Transaction Coordinator (MSDTC) or a bound session—is still active and has not been committed or rolled back. This typically happens due to improperly closed application connections, a misconfigured MSDTC service that fails to clean up orphaned transactions, or application code that attempts to nest incompatible transaction types (e.g., mixing BEGIN DISTRIBUTED TRANSACTION with an active local transaction). In Windows Server 2025 environments, this is often exacerbated by stricter security defaults requiring explicit DTC network access configuration.

Step-by-Step Resolution Guide

Step 1: Verify and Restart the MSDTC Service

  • Open Services.msc on the Windows Server 2025/Windows 11 machine.
  • Locate Distributed Transaction Coordinator, right-click, and select Restart.
  • Alternatively, use PowerShell: Restart-Service -Name MSDTC -Force
  • This clears any “stuck” transaction states that are blocking new sessions.

Step 2: Check Active Transactions in SQL Server

  • Open SQL Server Management Studio (SSMS) and run the following query to identify blocking sessions:
DBCC OPENTRAN;
SELECT * FROM sys.dm_tran_active_transactions;
  • Identify the transaction_id and associated session_id that is holding the lock.
  • Kill the offending session using KILL [session_id] if it is safe to do so.

Step 3: Reconfigure MSDTC Security Settings

  • Navigate to Component Services (dcomcnfg.exe) > Computers > My Computer > Distributed Transaction Coordinator > Local DTC.
  • Right-click Local DTC and select Properties, then go to the Security tab.
  • Ensure Network DTC Access, Allow Inbound/Outbound, and Enable XA Transactions (if applicable) are checked.
  • Click OK and restart the MSDTC service to apply the new security context.

Step 4: Audit Application Transaction Logic

  • Review the application code (e.g., .NET TransactionScope or JDBC connections) to ensure transactions are explicitly committed or rolled back in a finally block.
  • Ensure connection pooling settings are not reusing a connection that still has an enlisted transaction from a previous request.
  • Verify that SET XACT_ABORT ON is used in stored procedures to ensure transactions are rolled back immediately upon error.

Alternative or Verification Steps

  • Verification: After restarting the DTC service, run Get-Service MSDTC in PowerShell to confirm the status is “Running,” then attempt the failed transaction again to ensure Error 3982 no longer appears.
  • Alternative: If the error persists specifically in a clustered environment, verify that the MSDTC resource is online in Failover Cluster Manager and is not pointing to a corrupted CLB (Clustered Log Base) resource, which may require recreating the DTC resource group entirely.

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

Troubleshooting Guide: SQL Server Error 3983 – “Session Is Not Single Threaded”

Why This Error Happens

Error 3983 occurs when a transaction attempts to run a parallel (multi-threaded) operation while simultaneously participating in a marked transaction or distributed transaction that requires MARS (Multiple Active Result Sets) or single-threaded execution context. This typically happens when a session enlisted in a distributed transaction (via BEGIN DISTRIBUTED TRANSACTION or MSDTC) tries to execute a query that the Query Optimizer decides to parallelize across multiple schedulers. SQL Server 2025 enforces strict thread affinity for transactional consistency, so it blocks the operation rather than risk corrupting the transaction state.

Step-by-Step Resolution Guide

Step 1: Force Single-Threaded Execution via Query Hint

  • Add the OPTION (MAXDOP 1) hint to the specific query causing the failure.
  • Example:
  UPDATE dbo.YourTable
  SET Column1 = 'Value'
  WHERE ID = 1
  OPTION (MAXDOP 1);
  • This forces the Query Optimizer to skip parallel plan generation for that specific statement, bypassing the conflict with the active transaction session.

Step 2: Adjust Server-Level MAXDOP Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run the following to check current configuration:
  EXEC sp_configure 'show advanced options', 1;
  RECONFIGURE;
  EXEC sp_configure 'max degree of parallelism';
  • If the value is 0 (unlimited) and distributed transactions are common in your workload, set it to a fixed low value to reduce parallel plan generation:
  EXEC sp_configure 'max degree of parallelism', 1;
  RECONFIGURE WITH OVERRIDE;
  • Note: This is a server-wide change and may impact performance on other non-transactional workloads—apply with caution on production servers.

Step 3: Review and Refactor Distributed Transaction Code

  • Open the stored procedure or application code that initiates the transaction.
  • Look for BEGIN DISTRIBUTED TRANSACTION or linked server calls combined with complex joins/aggregations.
  • Refactor the code to separate the distributed transaction logic from heavy parallel-eligible queries. Run bulk/parallel-friendly operations before or after the transaction scope rather than inside it.

Step 4: Verify MSDTC Service Configuration (Windows Server 2025 / Windows 11)

  • Open Component Services (dcomcnfg.exe) on the host machine.
  • Navigate to Component Services > Computers > My Computer > Distributed Transaction Coordinator > Local DTC.
  • Right-click Local DTC, select Properties, and ensure Network DTC Access is enabled if transactions span multiple servers.
  • Restart the Distributed Transaction Coordinator service via services.msc to apply changes.

Alternative or Verification Steps

  • Verify the Fix: Re-run the original transaction/query that threw Error 3983. Check the SQL Server Error Log (Management > SQL Server Logs in SSMS) to confirm no recurrence of Event ID 3983.
  • Alternative Fix: If refactoring code is not feasible, wrap the specific parallel-triggering statement in its own local transaction scope outside the distributed transaction block, committing it independently before the distributed transaction begins.

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

Troubleshooting Guide: SQL Server Error 3981

“The transaction operation cannot be performed because there are pending requests working on this transaction.”

Why This Error Happens

This error occurs when SQL Server attempts to commit, rollback, or close a transaction while another session, worker thread, or asynchronous request still holds an active reference to it. This is commonly triggered by overlapping Multiple Active Result Sets (MARS) connections, orphaned batches, or a client-side timeout that disconnects before the server-side transaction fully completes. It can also surface when linked server calls or distributed transactions leave residual locks on the transaction context due to network interruption or driver-level connection pooling issues.

Step-by-Step Resolution Guide

Step 1: Identify Blocking Sessions and Pending Requests

  • Open SQL Server Management Studio (SSMS) and run the following query to check for active requests tied to the problematic transaction:
  SELECT session_id, status, command, wait_type, last_wait_type, transaction_id
  FROM sys.dm_exec_requests
  WHERE transaction_id = (SELECT transaction_id FROM sys.dm_tran_current_transaction);
  • Note any session_id values showing SUSPENDED or SLEEPING status, as these are likely holding the transaction open.

Step 2: Disable or Audit MARS on the Connection String

  • If your application uses Multiple Active Result Sets, inspect the connection string (typically in web.config, app.config, or ODBC DSN settings under C:\Windows\System32\odbcad32.exe).
  • Temporarily set MultipleActiveResultSets=False; to confirm if MARS concurrency is the root cause.
  • Restart the application pool or service in IIS Manager (inetmgr.exe) to apply the connection string change.

Step 3: Terminate Orphaned Sessions Safely

  • Use the session IDs gathered in Step 1 to safely kill orphaned connections:
  KILL <session_id>;
  • Avoid killing system session IDs (below 50), as these are reserved for internal SQL Server processes.

Step 4: Update SQL Server Native Client and Drivers

  • Navigate to Control Panel > Programs > Programs and Features on Windows Server 2025 / Windows 11.
  • Verify that the SQL Server Native Client (or Microsoft ODBC Driver 18+) is updated to the latest build, as older drivers mishandle asynchronous transaction completion signals.
  • Reboot the application server after updating to clear cached driver handles.

Step 5: Review Distributed Transaction Coordinator (MSDTC) Settings

  • Open dcomcnfg.exe (Component Services) and navigate to Component Services > Computers > My Computer > Distributed Transaction Coordinator.
  • Ensure Network DTC Access is enabled under Security Configuration, specifically allowing Inbound/Outbound transactions if linked servers are involved.
  • Restart the MSDTC service via services.msc to clear stale transaction locks.

Alternative or Verification Steps

  • Re-run the original transaction/stored procedure in isolation using SET XACT_ABORT ON; at the beginning of the script to ensure immediate rollback on error rather than leaving pending requests.
  • If the error persists under heavy load, check sys.dm_os_waiting_tasks for wait_type = 'TRANSACTION_MUTEX', which confirms a concurrency deadlock requiring application-level logic changes to serialize transaction commits.

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

Troubleshooting Guide: SQL Server Error 3980

Why This Error Happens

Error 3980 (“The request failed to run because the batch is aborted”) typically occurs during backup or restore operations within a transaction when a prior statement in the same batch encounters a fatal error, forcing SQL Server to terminate the entire batch. This is commonly triggered by marked transactions (WITH MARK) failing due to insufficient log space, a corrupted backup chain, or conflicting session states. It can also surface when permissions are revoked mid-transaction or when the backup/restore target file is locked or unreachable, causing SQL Server to abort rather than risk data inconsistency.

Step-by-Step Resolution Guide

Step 1: Verify the Transaction Log and Disk Space

  • Check available disk space on the drive hosting your .ldf log file and backup destination.
  • Run DBCC SQLPERF(LOGSPACE); to confirm the transaction log isn’t full.
  • If space is low, expand the log file via SQL Server Management Studio (SSMS) > Database Properties > Files, or run:
  ALTER DATABASE [YourDB] MODIFY FILE (NAME = YourDB_log, SIZE = 5GB);

Step 2: Check for Blocking Sessions or Orphaned Transactions

  • Run DBCC OPENTRAN('YourDB'); to identify long-running or orphaned transactions.
  • Use sp_who2 or query sys.dm_exec_requests to locate blocking session IDs (SPIDs).
  • Kill any stuck sessions causing the abort with KILL <SPID>; if safe to do so.

Step 3: Validate Backup/Restore File Integrity and Permissions

  • Confirm the SQL Server service account has read/write access to the backup folder path (e.g., D:\SQLBackups\).
  • Right-click the folder > Properties > Security tab, and ensure NT SERVICE\MSSQLSERVER has Full Control.
  • Run RESTORE VERIFYONLY FROM DISK = 'D:\SQLBackups\YourDB.bak'; to check for corruption.

Step 4: Review SQL Server Error Logs for Root Cause

  • Open SSMS > Management > SQL Server Logs, or navigate to:
    C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG
  • Search for the preceding error (e.g., Error 9002, 3041, or 5172) that triggered the 3980 abort.
  • Address the root error first, as 3980 is usually a secondary symptom.

Step 5: Rebuild the Transaction Using Isolated Batches

  • Break large multi-statement transactions into smaller, isolated batches separated by GO.
  • Re-run the operation using SET XACT_ABORT ON; at the start of the script to ensure cleaner rollback behavior on failure.

Alternative or Verification Steps

  • Verify the fix: Re-run the original backup/restore command and confirm it completes with “Processed X pages” success messages instead of aborting.
  • Alternative: If the issue persists on Windows Server 2025, run DBCC CHECKDB('YourDB') WITH NO_INFOMSGS; to rule out underlying database corruption as the root trigger.

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

Why This Error Happens

Error 3979 occurs when the SQL Server Transaction Manager (TM) — responsible for coordinating distributed transactions through MSDTC (Microsoft Distributed Transaction Coordinator) — fails to receive an acknowledgment from a participating resource manager within the expected internal timeout window. This is typically caused by network latency between nodes, a misconfigured or stalled MSDTC service, or blocking/locking contention that prevents the transaction log from flushing the commit record in time. In some cases, a corrupted MSDTC security configuration or outdated firewall rule silently drops the TM handshake packets, causing the request to be abandoned.

Step-by-Step Resolution Guide

Step 1: Verify and Restart the MSDTC Service

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Locate Distributed Transaction Coordinator, right-click, and select Restart.
  • Alternatively, run in an elevated PowerShell session:
  Restart-Service -Name MSDTC -Force
  • Confirm the service startup type is set to Automatic to prevent recurrence after reboot.

Step 2: Check Network and Firewall Configuration

  • Ensure TCP port 135 (RPC endpoint mapper) and the dynamic RPC port range are open between all nodes involved in the distributed transaction.
  • Run dtcping.exe between the SQL Server host and the remote TM to confirm two-way communication.
  • In Windows Defender Firewall with Advanced Security, verify inbound/outbound rules for “Distributed Transaction Coordinator” are enabled on both source and target servers.

Step 3: Review SQL Server Transaction Log and Blocking Sessions

  • Run the following query to identify long-running or blocked transactions tied to the TM request:
  SELECT session_id, blocking_session_id, wait_type, wait_time, status
  FROM sys.dm_exec_requests
  WHERE blocking_session_id <> 0;
  • If a session is holding locks for an extended period, terminate it safely using KILL <session_id>; after confirming it is not business-critical.
  • Check the transaction log file size and growth settings in SQL Server Management Studio (SSMS) under Database Properties > Files — ensure Autogrowth is not restrictively capped.

Step 4: Reconfigure MSDTC Security Settings

  • Open Component Services (dcomcnfg.exe) → Computers → My Computer → Distributed Transaction Coordinator → Local DTC → Properties → Security tab.
  • Enable Network DTC Access, Allow Inbound/Outbound, and Mutual Authentication Required (or Incoming Caller Authentication Required if operating in a mixed-trust environment).
  • Apply changes and restart the MSDTC service again to commit the new configuration.

Step 5: Apply Latest SQL Server 2025 Cumulative Update

  • Confirm your instance build number via:
  SELECT @@VERSION;
  • Download and install the latest Cumulative Update (CU) from the Microsoft Update Catalog, as several TM timeout handling fixes are often bundled into servicing updates.
  • Reboot the server after installation to ensure the TM driver stack reloads cleanly.

Alternative or Verification Steps

  • Re-run the distributed transaction that originally failed and confirm Error 3979 no longer appears in the SQL Server Error Log or Windows Event Viewer (Application log).
  • If the issue persists, enable Trace Flag 3904 temporarily to capture verbose TM diagnostic logging, then review sys.dm_tran_active_transactions for transactions stuck in a PREPARED state before escalating to Microsoft Support.

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

Troubleshooting Guide: SQL Server Error 3977 — “The Savepoint Name Cannot Be NULL. The Batch Has Been Aborted.”

Why This Error Happens

This error occurs when a transaction attempts to roll back to a savepoint, but the savepoint name was never properly defined or was passed as a NULL value due to a scripting error or variable scope issue. It is commonly triggered by dynamically generated SQL, ORM frameworks (like Entity Framework or Hibernate), or stored procedures where a variable intended to hold the savepoint name was not initialized before the SAVE TRANSACTION or ROLLBACK TRANSACTION statement executed. In rare cases, this can also surface due to corrupted transaction log metadata in SQL Server 2025 following an improper shutdown.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Transact-SQL Code

  • Open SQL Server Management Studio (SSMS) and locate the stored procedure, trigger, or application code referenced in the error log.
  • Check C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the exact batch that triggered Error 3977.
  • Search the code for SAVE TRANSACTION and ROLLBACK TRANSACTION statements that use a variable (e.g., @SavepointName) rather than a static string.

Step 2: Initialize and Validate the Savepoint Variable

  • Ensure the variable used for the savepoint name is explicitly declared and assigned a non-NULL value before the SAVE TRANSACTION call:
  DECLARE @SavepointName NVARCHAR(32) = 'MySavePoint';
  SAVE TRANSACTION @SavepointName;
  • If using an ORM (Entity Framework Core, NHibernate, etc.), verify that the application’s transaction-naming logic isn’t passing an empty string or null object reference during nested transaction calls.
  • Add a NULL check guard clause: IF @SavepointName IS NULL SET @SavepointName = 'DefaultSP';

Step 3: Update SQL Server 2025 Database Compatibility Level

  • Open a new query window in SSMS and run the following to confirm the compatibility level of the database:
  SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • If the compatibility level is outdated (below 160), update it to align with SQL Server 2025 standards to ensure savepoint handling behaves as expected:
  ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 170;

Step 4: Restart the SQL Server Service to Clear Session State

  • Open the Services console on Windows Server 2025 / Windows 11 by running services.msc.
  • Locate SQL Server (MSSQLSERVER), right-click, and select Restart to clear any lingering transaction contexts or cached execution plans.
  • Alternatively, run the following in PowerShell (as Administrator):
  Restart-Service -Name 'MSSQLSERVER' -Force

Alternative or Verification Steps

  • Re-run the original batch or stored procedure in SSMS with SET NOCOUNT ON; and manually execute the SAVE TRANSACTION line in isolation to confirm the variable now holds a valid string value.
  • If the error persists despite code fixes, use SQL Server Profiler (or Extended Events) to trace the exact T-SQL batch sent by the application layer, as the NULL value may be originating from a parameterized query at the driver level (e.g., ODBC or JDBC connection string misconfiguration).

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

Troubleshooting Guide: SQL Server Error 3978

Beginning a new transaction after rollback to save point is not allowed

Why This Error Happens

This error occurs when an application attempts to initiate a new transaction immediately after rolling back to a savepoint within the same batch, without properly committing or fully rolling back the parent transaction first. SQL Server 2025 enforces strict transaction state validation, and a rollback to a savepoint only reverts data changes — it does not close out the outer transaction context, leaving the connection in an ambiguous state. This is commonly triggered by poorly structured transaction logic in stored procedures, ORMs (like Entity Framework or Dapper), or application connection pooling where a prior transaction wasn’t fully disposed before a new one was opened on the same connection.

Step-by-Step Resolution Guide

Step 1: Review the Transaction Logic in the Source Code

  • Locate the stored procedure or application code throwing Error 3978 using SQL Server Profiler or Extended Events (xEvents) filtered on error_reported with error number 3978.
  • Check for a pattern like SAVE TRANSACTION, followed by ROLLBACK TRANSACTION SavepointName, and then immediately BEGIN TRANSACTION without an intervening COMMIT or full ROLLBACK.
  • Ensure every BEGIN TRANSACTION has a matching COMMIT TRANSACTION or a full ROLLBACK TRANSACTION (without a savepoint name) before starting a new one.

Step 2: Correct the Transaction Control Flow in T-SQL

  • Modify the procedure logic so that after ROLLBACK TRANSACTION SavepointName, you either continue work inside the same outer transaction or issue a full ROLLBACK TRANSACTION (no savepoint name) to close it out completely.
  • Example corrected pattern:
  BEGIN TRANSACTION;
  SAVE TRANSACTION MySavePoint;
  -- logic here
  ROLLBACK TRANSACTION MySavePoint;
  -- continue or commit the SAME transaction, do not start a new one here
  COMMIT TRANSACTION;
  • Avoid nesting a BEGIN TRANSACTION call directly after a savepoint rollback within the same @@TRANCOUNT scope.

Step 3: Audit Application-Level Connection and ORM Settings

  • On Windows Server 2025/Windows 11 hosts, check the application’s connection string for Enlist=true or pooling settings that may reuse a connection with a lingering transaction state.
  • For .NET apps, verify TransactionScope objects are disposed properly using using blocks and that nested scopes use TransactionScopeOption.Required correctly.
  • Restart the application pool (IIS) or the service host to clear any connections stuck in a bad transaction state:
  Restart-WebAppPool -Name "YourAppPoolName"

Step 4: Validate SQL Server Configuration and Patch Level

  • Confirm SQL Server 2025 is on the latest Cumulative Update via SQL Server Configuration Manager or SELECT @@VERSION;.
  • Check sys.dm_tran_active_transactions and sys.dm_tran_session_transactions DMVs to identify sessions stuck with uncommitted nested transactions.
  • If a session is orphaned, isolate and kill it using KILL <session_id>; after confirming it is safe to terminate.

Alternative or Verification Steps

  • Re-run the transaction/procedure in SQL Server Management Studio (SSMS) manually, checking @@TRANCOUNT before and after each COMMIT/ROLLBACK to confirm it returns to 0 cleanly.
  • If the error persists, wrap the entire logic in a TRY...CATCH block with XACT_STATE() checks to programmatically detect and fully roll back doomed transactions before allowing any new BEGIN TRANSACTION call.

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

Troubleshooting Guide: Error 3976 – “The Transaction Name Has the Odd Length %d”

Why This Error Happens

This error occurs when SQL Server’s internal transaction logging mechanism receives a transaction name or savepoint name with an invalid byte length, typically caused by encoding mismatches between Unicode (NVARCHAR) and non-Unicode string handling in the transaction log stream. It frequently surfaces due to corrupted metadata in the transaction log cache, improperly terminated strings passed from client drivers (such as outdated ODBC or OLE DB providers), or low-level corruption in the syscommittab or internal log buffer structures. In rare cases, this is triggered by a mismatch between the SQL Server 2025 engine build and an incompatible client-side library attempting to mark a distributed transaction with a malformed name.

Step-by-Step Resolution Guide

Step 1: Verify and Update Client Connectivity Drivers

  • Check the application or script that initiates the transaction (e.g., BEGIN TRAN TransactionName WITH MARK) for improperly encoded strings.
  • Ensure the client is using the latest Microsoft ODBC Driver 18+ or OLE DB Driver 19+, as older drivers may pass ANSI strings where Unicode is expected.
  • On Windows Server 2025 / Windows 11, go to Control Panel > ODBC Data Sources (64-bit) and confirm the driver version listed matches the latest Microsoft release.

Step 2: Run Database Consistency Checks

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Execute DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to rule out corruption in system tables affecting transaction logging.
  • Review the output for any allocation or consistency errors tied to syscommittab or log sequence number (LSN) chains.

Step 3: Inspect and Sanitize Transaction Names in T-SQL Code

  • Search stored procedures, triggers, and application code for dynamically generated transaction names (e.g., concatenated strings with special characters or null terminators).
  • Replace any dynamically built transaction name strings with static, short, alphanumeric names (under 32 characters) to avoid encoding/length mismatches.
  • Example fix:
BEGIN TRAN MyCleanTransactionName;
-- instead of
BEGIN TRAN (@DynamicallyBuiltString);

Step 4: Restart the SQL Server Service and Clear Log Cache

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Locate SQL Server (MSSQLSERVER) or your named instance, right-click, and select Restart.
  • This clears any transient in-memory log buffer corruption that may be causing the odd-length string error.

Step 5: Apply the Latest Cumulative Update (CU) for SQL Server 2025

  • Navigate to the Microsoft Download Center and verify your current build via:
SELECT @@VERSION;
  • Download and install the latest Cumulative Update for SQL Server 2025, as this issue has known fixes in post-RTM servicing releases related to transaction log string handling.

Alternative or Verification Steps

  • After applying fixes, re-run the original transaction or batch in SSMS and confirm no Error 3976 appears in the SQL Server Error Log (EXEC sp_readerrorlog;).
  • If the error persists, use SQL Server Profiler or Extended Events to trace the exact BEGIN TRAN statement and byte length being passed, then correct the offending application code at the source.

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

Troubleshooting Guide: Error 3975 – varchar(max) Not Supported for sp_getbindtoken

Why This Error Happens

This error occurs because sp_getbindtoken is used to create a bind token for distributed transactions across multiple connections, and this system procedure does not support large object (LOB) data types such as varchar(max), nvarchar(max), or varbinary(max). When a transaction context includes a session or query referencing these MAX data types while attempting to bind to another connection, SQL Server 2025 rejects the operation and aborts the batch. This is typically encountered in applications performing distributed or linked server transactions where large object variables are improperly passed between connections.

Step-by-Step Resolution Guide

Step 1: Identify the Query or Procedure Triggering the Bind

  • Review the application code or stored procedure that calls sp_getbindtoken or sp_bindsession.
  • Check SQL Server Profiler or Extended Events to capture the exact statement executing at the time of Error 3975.
  • Look specifically for variables or columns declared as varchar(max), nvarchar(max), or varbinary(max) within the transaction scope.

Step 2: Modify Data Types to Avoid MAX Types in Bound Transactions

  • Change varchar(max) columns/variables to a fixed-length equivalent (e.g., varchar(8000)) if the data size permits.
  • If large data truly exceeds 8000 characters, restructure the logic to process LOB data outside the bound transaction scope.
  • Update any affected table schemas using SQL Server Management Studio (SSMS) or via T-SQL:
  ALTER TABLE dbo.YourTable 
  ALTER COLUMN YourColumn VARCHAR(8000);

Step 3: Refactor Distributed Transaction Logic

  • Avoid passing MAX data types directly through sp_getbindtoken/sp_bindsession workflows.
  • Use a staging table or temporary table to hold LOB data separately, then join or merge results after the bound transaction completes.
  • Ensure MSDTC (Microsoft Distributed Transaction Coordinator) settings are correctly configured in Component Services (dcomcnfg.exe) under Windows Server 2025 if the issue is tied to distributed transactions.

Step 4: Apply Latest SQL Server 2025 Cumulative Update

  • Open SQL Server Configuration Manager and verify the current build version.
  • Navigate to Microsoft’s official download center and install the latest Cumulative Update (CU) for SQL Server 2025.
  • Restart the SQL Server service via services.msc or run:
  Restart-Service -Name 'MSSQLSERVER'

Alternative or Verification Steps

  • Re-run the original transaction/query after applying the data type change — confirm Error 3975 no longer appears in the SQL Server error log (Error Logs folder under C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\).
  • If the error persists, isolate the transaction without sp_getbindtoken entirely and use BEGIN DISTRIBUTED TRANSACTION directly, bypassing manual session binding as an alternative workaround.

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

Troubleshooting Guide: SQL Server Error 3974 – Exclusive Mode Database Limit Exceeded

Why This Error Happens

This error occurs when the number of databases opened in exclusive mode within a single workspace or session exceeds the internal threshold defined by SQL Server 2025’s resource governor. It is typically triggered by applications or scripts that open database handles without properly releasing locks, orphaned connections from crashed sessions, or a misconfigured workspace pooling setting that caps concurrent exclusive-mode database access. In some cases, corrupted tempdb metadata can also cause SQL Server to miscount active exclusive handles, falsely triggering the limit.

Step-by-Step Resolution Guide

Step 1: Identify Active Exclusive-Mode Sessions

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run the following query to list current sessions holding exclusive locks:
  SELECT request_session_id, resource_database_id, request_mode 
  FROM sys.dm_tran_locks 
  WHERE request_mode = 'X';
  • Note any session IDs (SPIDs) that appear stale or orphaned.

Step 2: Terminate Orphaned or Excessive Sessions

  • For each problematic SPID identified in Step 1, run:
  KILL <session_id>;
  • Alternatively, restart the SQL Server service via Services.msc on Windows Server 2025/Windows 11 to force-release all exclusive handles if KILL commands fail.

Step 3: Adjust Workspace Exclusive Mode Limit

  • Navigate to Computer Configuration > Administrative Templates > SQL Server > Workspace Settings in the Local Group Policy Editor (gpedit.msc), or edit the instance-level configuration directly.
  • Modify the max exclusive db handles setting using:
  EXEC sp_configure 'show advanced options', 1;
  RECONFIGURE;
  EXEC sp_configure 'max worker threads', 0; -- allows auto-scaling
  RECONFIGURE;
  • Restart the SQL Server service for changes to take effect.

Step 4: Check and Repair tempdb Metadata

  • Run DBCC CHECKDB (tempdb) to rule out corruption affecting session counting.
  • If corruption is found, restart the instance to rebuild tempdb automatically, as tempdb is recreated on every SQL Server startup.

Alternative or Verification Steps

  • After applying fixes, re-run the application workload that originally triggered Error 3974 and monitor sys.dm_tran_locks to confirm exclusive-mode session counts stay below the configured threshold.
  • If the error persists, apply the latest Cumulative Update (CU) for SQL Server 2025, as workspace handle-counting bugs are occasionally addressed in servicing releases.

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

Troubleshooting Guide: Error 3973 – Database In Use by Another Thread in Exclusive Mode

Why This Error Happens

This error occurs when an internal SQL Server operation, such as a database snapshot creation, DBCC CHECKDB, or a restore operation, attempts to acquire an exclusive lock on a database workspace that is already held by another concurrent thread or session. It is frequently triggered when maintenance tasks (like CHECKDB with data_purity or repair options) run simultaneously with other transactional activity against the same database. In some cases, this can also surface due to an improperly closed internal snapshot used by SQL Server to maintain transactional consistency during consistency checks.

Step-by-Step Resolution Guide

Step 1: Identify Conflicting Sessions and Processes

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance on your Windows Server 2025 / Windows 11 machine.
  • Run sp_who2 or query sys.dm_exec_requests and sys.dm_tran_locks to identify sessions holding locks on the database in question.
  • Look specifically for sessions with DbId matching your target database and a request_mode of X (exclusive).

Step 2: Terminate Blocking Sessions Safely

  • Once you identify the blocking session ID (SPID), verify it is not a critical system process before terminating it.
  • Use KILL <SPID> in a new query window to terminate the conflicting session.
  • If the issue stems from a DBCC CHECKDB operation, allow it to complete fully before re-running any other exclusive operations, as interrupting DBCC mid-process can cause further workspace conflicts.

Step 3: Check for Orphaned Internal Snapshots

  • Navigate to the default data directory, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\, and look for leftover snapshot files (usually named with a GUID pattern and .ss extension).
  • These orphaned snapshot files can occur if a previous DBCC operation was forcibly terminated.
  • Restart the SQL Server service via services.msc or run net stop MSSQLSERVER followed by net start MSSQLSERVER in an elevated Command Prompt to clear any stuck internal snapshot handles.

Step 4: Serialize Maintenance Operations

  • Reschedule maintenance jobs (DBCC CHECKDB, index rebuilds, backups) in SQL Server Agent so they do not overlap on the same database.
  • Open SQL Server Agent, navigate to Jobs, and adjust the Schedules tab to stagger execution times with at least a 15-30 minute buffer between jobs targeting the same database.

Step 5: Apply Latest Cumulative Update

  • Verify your current build version by running SELECT @@VERSION;.
  • If you are not on the latest Cumulative Update (CU) for SQL Server 2025, download and apply it from the Microsoft Update Catalog, as workspace locking issues are often addressed in service packs/CUs.

Alternative or Verification Steps

  • After applying the fixes, re-run the original operation (e.g., DBCC CHECKDB or backup/restore) during a low-activity window and confirm it completes without Error 3973 appearing in the SQL Server Error Log (ERRORLOG file in the MSSQL\LOG directory).
  • If the error persists, consider restarting the SQL Server instance entirely during a maintenance window to clear any lingering internal workspace locks that a simple service restart did not resolve.

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

Troubleshooting Guide: Error 3972 — Incorrect TDS Protocol / Transaction Manager Event Length Mismatch

Why This Error Happens

Error 3972 occurs when the SQL Server Transaction Manager receives a Tabular Data Stream (TDS) packet whose declared event length does not match the actual byte length received, indicating protocol-level data corruption. This is typically caused by network-layer interference (such as a misconfigured firewall, proxy, or load balancer fragmenting packets), a mismatched or outdated network driver, or corrupted TDS packets resulting from an unstable connection between the client and the SQL Server instance. It can also surface after incomplete patching of SQL Server 2025 or when MS DTC (Distributed Transaction Coordinator) communication is interrupted mid-transaction.

Step-by-Step Resolution Guide

Step 1: Verify Network Integrity Between Client and Server

  • Run ping -t <ServerName> and tracert <ServerName> to check for packet loss or latency spikes during the error window.
  • Disable TCP Chimney Offload and TCP/IP Checksum Offload on the NIC, as these features are known to corrupt TDS packets on Windows Server 2025:
    Disable-NetAdapterChecksumOffload -Name "*" -TcpIPv4
  • Check Event Viewer under Applications and Services Logs > Microsoft > Windows > TCPIP for dropped packet warnings.

Step 2: Validate MS DTC Configuration

  • Open Component Services (comexp.msc) and navigate to Component Services > Computers > My Computer > Distributed Transaction Coordinator > Local DTC.
  • Right-click Local DTC, select Properties, and ensure Network DTC Access is enabled with both Allow Inbound and Allow Outbound checked.
  • Restart the MSDTC service:
    Restart-Service MSDTC -Force
  • Confirm the same DTC security settings are mirrored on both the application server and the SQL Server 2025 host.

Step 3: Update Network Drivers and SQL Native Client

  • Update the NIC driver via Device Manager (devmgmt.msc) or directly from the hardware vendor’s site (Intel/Broadcom/Mellanox drivers are common culprits).
  • Ensure the client application is using the latest Microsoft OLE DB Driver or ODBC Driver compatible with SQL Server 2025 (avoid legacy SQL Native Client 11.0 if still in use).
  • Apply the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Update Catalog, as TDS parsing fixes are frequently shipped in CUs.

Step 4: Inspect and Reset the TCP/IP Stack

  • If the issue persists only on the Windows Server 2025 host, reset the TCP/IP stack to rule out stack-level corruption:
    netsh int ip reset
    netsh winsock reset
  • Reboot the server after running these commands, as a soft restart will not fully apply the reset.

Alternative or Verification Steps

  • To verify the fix, run a distributed transaction test query (e.g., BEGIN DISTRIBUTED TRANSACTION) from the client and confirm it commits without triggering Error 3972 in the SQL Server Error Log.
  • If the error persists after all steps, capture a network trace using Wireshark or Microsoft Network Monitor filtered on port 1433 to identify the exact packet where length mismatch occurs, then escalate to Microsoft Support with the trace file and PSSDIAG output.

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

Troubleshooting Guide: SQL Server Error 3970

Why This Error Happens

Error 3970 occurs when multiple threads or processes attempt to issue conflicting commands (such as COMMIT, ROLLBACK, or BEGIN) against the same transaction simultaneously. This typically happens due to application code that reuses a connection or transaction object across multiple threads without proper synchronization, or when a previous command on the connection hasn’t fully completed (is still pending) before a new one is issued. In some cases, this is triggered by MARS (Multiple Active Result Sets) being improperly managed, or by an application timeout that fires a rollback while the original query is still executing.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting Session and Query

  • Open SQL Server Management Studio (SSMS) and run sp_who2 or query sys.dm_exec_requests to identify the session ID (SPID) throwing the error.
  • Check sys.dm_tran_active_transactions joined with sys.dm_tran_session_transactions to see if a single session has multiple open transactions.
  • Review the SQL Server error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the exact timestamp and context of the 3970 error.

Step 2: Audit Application Connection and Threading Logic

  • Verify the application is not sharing a single SqlConnection or SqlTransaction object across multiple threads concurrently.
  • Check the connection string for MultipleActiveResultSets=True — if present, ensure the application correctly awaits each command before issuing another on the same connection.
  • Look for mismatched BEGIN TRAN / COMMIT / ROLLBACK pairs in stored procedures, especially inside nested TRY/CATCH blocks where a ROLLBACK might fire while another batch is still active.

Step 3: Adjust Timeout and Retry Settings

  • Increase the command timeout value in the application’s connection settings (default is often 30 seconds) to prevent premature ROLLBACK calls from the client while a long-running query is still active.
  • Navigate to the application config (e.g., web.config or appsettings.json) and update the CommandTimeout property.
  • Implement application-level retry logic using exponential backoff rather than immediate transaction aborts.

Step 4: Restart the Affected Session or Service

  • If the issue persists on a specific SPID, kill the blocking session using KILL <SPID> in SSMS.
  • If the conflict is widespread, restart the SQL Server service via services.msc or run Restart-Service MSSQLSERVER in an elevated PowerShell prompt on Windows Server 2025.
  • Clear any orphaned connections by cycling the application’s connection pool (recycle the IIS App Pool or restart the service account).

Alternative or Verification Steps

  • To verify the fix, run the application’s transaction-heavy workflow under load and monitor sys.dm_tran_active_transactions to confirm no session shows multiple simultaneous “ACTIVE” transaction states.
  • If the error persists after code review, as a workaround, disable MARS in the connection string and ensure each thread opens its own dedicated SqlConnection instance.

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

Troubleshooting Guide: SQL Server Error 3971 — “The Server Failed to Resume the Transaction”

Why This Error Happens

This error typically occurs when SQL Server 2025 attempts to resume a marked or distributed transaction (identified by the hexadecimal descriptor in the error message) but cannot locate its corresponding state in memory or in the transaction log. This usually happens due to a mismatched transaction descriptor caused by a failed session reconnect, an abrupt application disconnect during a bound session, or corruption in the transaction log that prevents SQL Server from mapping the transaction context correctly. In some cases, this is also triggered by MSDTC (Microsoft Distributed Transaction Coordinator) communication failures between Windows Server 2025 and the SQL Server instance.

Step-by-Step Resolution Guide

Step 1: Verify the Transaction Descriptor and Session State

  • Query sys.dm_tran_active_transactions and sys.dm_tran_session_transactions to check if the transaction ID referenced in the %I64x descriptor still exists.
  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for correlating entries around the same timestamp.
  • Identify whether the application is using sp_getbindtoken / sp_bindsession for bound connections, as this is a common trigger.

Step 2: Restart and Reset MSDTC Service

  • Open Services.msc on Windows Server 2025 and locate Distributed Transaction Coordinator.
  • Restart the service: net stop msdtc && net start msdtc.
  • Validate MSDTC security settings via dcomcnfg.exe → Component Services → My Computer → Distributed Transaction Coordinator → Local DTC → Properties → Security tab. Ensure “Network DTC Access” and “Allow Inbound/Outbound” are enabled if distributed transactions are used.

Step 3: Check for Transaction Log Corruption

  • Run DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS, ALL_ERRORS; to rule out log or page-level corruption.
  • If corruption is found, restore from the last known good backup rather than attempting repair with data loss as a first option.

Step 4: Update SQL Server 2025 Cumulative Updates

  • Navigate to SQL Server Installation Center and check the current build version using SELECT @@VERSION;.
  • Apply the latest Cumulative Update (CU) from Microsoft, as this specific error has known fixes related to session multiplexing (MARS) and bound transaction handling in early builds of SQL Server 2025.

Alternative or Verification Steps

  • To verify the fix, re-run the application workload that previously failed and monitor sys.dm_tran_active_transactions for orphaned or long-running transactions that fail to resume.
  • As an alternative, if the error persists only under MARS (Multiple Active Result Sets) connections, disable MultipleActiveResultSets=True in the application’s connection string to confirm if the issue is isolated to session multiplexing.

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

Troubleshooting Guide: Error 3969 – Distributed Transaction Not Supported in SQL Server Internal Query

Why This Error Happens

Error 3969 occurs when SQL Server internally attempts to execute a query within the context of a distributed transaction that it does not support for that specific operation, most commonly during logon trigger execution. This typically happens because the logon trigger (or a nested process it calls) enlists in a distributed transaction via BEGIN DISTRIBUTED TRANSACTION or implicit escalation through MSDTC, which SQL Server’s internal metadata queries cannot process. Additionally, this can surface due to corrupted session state or lingering transaction contexts left open by poorly structured triggers or stored procedures that fail to commit/rollback properly before the connection is fully established.

Step-by-Step Resolution Guide

Step 1: Audit and Modify the Logon Trigger Definition

  • Navigate to Object Explorer > Server Objects > Triggers in SQL Server Management Studio (SSMS) 2025.
  • Script out the existing logon trigger using sp_helptext [TriggerName] to review the full T-SQL logic.
  • Remove any explicit calls to BEGIN DISTRIBUTED TRANSACTION or linked server queries that force a distributed transaction promotion.
  • If cross-database queries are required, ensure they target databases on the same SQL Server instance to avoid triggering MSDTC.

Step 2: Verify MSDTC and Transaction Settings

  • Open Component Services (comexp.msc) on your Windows Server 2025 or Windows 11 machine.
  • Navigate to Component Services > Computers > My Computer > Distributed Transaction Coordinator > Local DTC.
  • Right-click Local DTC, select Properties, and check the Security tab to ensure “Network DTC Access” settings align with your environment (enable only if cross-server transactions are explicitly required).
  • Restart the MSDTC service via PowerShell if changes are made:
  Restart-Service MSDTC -Force

Step 3: Disable Implicit Transaction Escalation

  • In SSMS, open a new query window connected to the affected instance.
  • Check the XACT_ABORT and IMPLICIT_TRANSACTIONS settings within the trigger body; ensure they are not inadvertently set to ON in a way that forces escalation.
  • Run the following command to inspect current session settings if the trigger is still active:
  DBCC USEROPTIONS;
  • If a linked server is involved, modify its configuration to disable promotion of distributed transactions:
  EXEC sp_serveroption 'LinkedServerName', 'remote proc transaction promotion', 'false';

Step 4: Disable and Test the Logon Trigger

  • If the error persists and locks you out of the instance, start SQL Server in a Dedicated Admin Connection (DAC) mode.
  • Use sqlcmd -S servername -A to connect via the admin channel.
  • Disable the problematic trigger temporarily to restore access:
  DISABLE TRIGGER [TriggerName] ON ALL SERVER;
  • Re-enable the trigger only after the distributed transaction logic has been fully removed from the script.

Alternative or Verification Steps

  • Verification: Attempt a standard login via SSMS or sqlcmd after re-enabling the trigger; monitor the SQL Server Error Log (Management > SQL Server Logs) to confirm Error 3969 no longer appears during the connection handshake.
  • Alternative: If the trigger logic absolutely requires cross-server validation, refactor the logic to use a Service Broker asynchronous call instead of a synchronous linked server query, which bypasses the distributed transaction limitation entirely.

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

Troubleshooting Guide: SQL Server Error 3968 – Snapshot Isolation Unavailable Due to Undocumented Trace Flags

Why This Error Happens

This error occurs because SQL Server 2025 was started with one or more undocumented (internal/diagnostic) trace flags that explicitly disable row versioning support at the engine level. Row versioning is a prerequisite for both snapshot isolation and read committed snapshot isolation (RCSI), and certain internal trace flags—often used by Microsoft support for diagnostic purposes—block this subsystem from initializing. As a result, any transaction attempting to use SNAPSHOT isolation or any database with RCSI enabled will fail because the versioning store cannot be created.

Step-by-Step Resolution Guide

Step 1: Identify Active Trace Flags on the Instance

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run DBCC TRACESTATUS(-1); to list all globally enabled trace flags.
  • Cross-reference the output against known documented trace flags; any flag not listed in official Microsoft documentation is a candidate for removal.
  • Alternatively, check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for a line listing startup trace flags.

Step 2: Inspect SQL Server Startup Parameters

  • Open SQL Server Configuration Manager from the Start menu on Windows Server 2025 / Windows 11.
  • Navigate to SQL Server Services > right-click your instance (e.g., SQL Server (MSSQLSERVER)) > Properties.
  • Go to the Startup Parameters tab and review all entries prefixed with -T (these represent trace flags passed at boot).
  • Note down any undocumented flag numbers (commonly internal flags outside the publicly documented range) for removal.

Step 3: Remove the Undocumented Trace Flags

  • In the Startup Parameters tab, select the problematic -T<flag_number> entry and click Remove.
  • Click Apply, then restart the SQL Server service for changes to take effect.
  • If the flags were set via a Windows Registry edit or a startup script instead of Configuration Manager, locate and edit the registry key at:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQLServer\Parameters
  • Delete the corresponding SQLArgn value containing the unwanted trace flag.

Step 4: Restart the SQL Server Service

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Locate SQL Server (MSSQLSERVER) (or named instance equivalent).
  • Right-click and select Restart to apply the startup parameter changes.
  • Confirm the service returns to a Running state without errors in the Windows Event Viewer.

Step 5: Re-enable Snapshot Isolation on the Database

  • Connect via SSMS and run the following T-SQL to enable the required isolation features:
  ALTER DATABASE [YourDatabaseName] SET ALLOW_SNAPSHOT_ISOLATION ON;
  ALTER DATABASE [YourDatabaseName] SET READ_COMMITTED_SNAPSHOT ON;
  • Ensure no active connections are blocking the ALTER DATABASE command; switch to single-user mode temporarily if needed.

Alternative or Verification Steps

  • Verify the fix by querying sys.databases with SELECT name, snapshot_isolation_state_desc, is_read_committed_snapshot_on FROM sys.databases WHERE name = 'YourDatabaseName';—both values should confirm the features are active.
  • If removing trace flags is not feasible (e.g., required by a support case), consider migrating the workload to a different instance without the conflicting startup parameters, or contact Microsoft Support to identify a safe equivalent documented flag.

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

Troubleshooting Guide: Error 3967 – Insufficient Space in tempdb Version Store

Why This Error Happens

This error occurs when the tempdb version store grows faster than SQL Server 2025 can reclaim space, typically because tempdb has run out of free disk space or has hit its configured maximum file size growth limit. Long-running transactions, uncommitted transactions, or heavy snapshot isolation/read-committed snapshot isolation (RCSI) usage prevent old row versions from being cleaned up, causing the version store to balloon. When SQL Server can no longer allocate space for new versions, it marks the oldest/largest offending transactions as victims and rolls them back to free up space.

Step-by-Step Resolution Guide

Step 1: Identify the Transactions Blocking Version Store Cleanup

  • Run the following query to find long-running or orphaned transactions holding onto version store entries:
SELECT session_id, transaction_id, elapsed_time_seconds, database_id
FROM sys.dm_tran_active_snapshot_database_transactions
ORDER BY elapsed_time_seconds DESC;
  • Cross-reference session_id with sys.dm_exec_sessions and sys.dm_exec_requests to identify the application or query causing the long transaction.
  • Look for sessions in a “sleeping” state with open transactions — these are prime candidates for manual intervention.

Step 2: Free Up tempdb Space Immediately

  • Kill any identified long-running/idle transactions using KILL <session_id>; after confirming it is safe to terminate.
  • Check current tempdb space usage:
SELECT SUM(unallocated_extent_page_count) AS free_pages
FROM sys.dm_db_file_space_usage;
  • If tempdb data files are undersized, add or expand tempdb files via SSMS or T-SQL:
ALTER DATABASE tempdb 
MODIFY FILE (NAME = tempdev, SIZE = 20480MB, FILEGROWTH = 1024MB);
  • Ensure the drive hosting tempdb (commonly D:\SQLData\tempdb.mdf or a dedicated SSD volume) has adequate free disk space — at least 20-30% headroom.

Step 3: Reconfigure tempdb Layout and Growth Settings

  • Distribute tempdb across multiple data files (one per CPU core, up to 8) to reduce contention and improve throughput:
ALTER DATABASE tempdb 
ADD FILE (NAME = tempdev2, FILENAME = 'E:\SQLData\tempdb2.ndf', SIZE = 8192MB, FILEGROWTH = 1024MB);
  • Set a fixed, generous initial size with moderate autogrowth increments (avoid percentage-based growth) to prevent fragmentation and allocation stalls.
  • Move tempdb files to a dedicated high-speed disk (NVMe/SSD) separate from user databases if not already configured.

Step 4: Review and Adjust Isolation Level Usage

  • Audit applications using snapshot isolation or RCSI, as these are the primary consumers of the version store:
SELECT name, is_read_committed_snapshot_on, snapshot_isolation_state_desc
FROM sys.databases;
  • Work with application teams to shorten transaction scope and commit transactions promptly, avoiding open transactions during user think-time or batch waits.
  • Consider enabling trace flag 3427 or adjusting application-level retry logic to handle transient victim rollbacks gracefully.

Alternative or Verification Steps

  • Verify the fix by monitoring sys.dm_db_file_space_usage and the version store size over 24-48 hours to confirm it stabilizes rather than continuously growing.
  • If the error persists after resizing tempdb, check Windows Server 2025 disk-level constraints (e.g., Storage Spaces quotas, VHDX dynamic disk limits) and consider migrating tempdb to a larger dedicated volume.

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

Troubleshooting Guide: Error 3965 – PROMOTE TRANSACTION Request Failed

Why This Error Happens

This error occurs when application code calls PROMOTE TRANSACTION (escalating a local transaction to a distributed transaction via MSDTC) without an active local transaction context present on the connection. It commonly happens due to improper transaction scoping in application code, connection pooling issues that reset the session state, or a mismatch between TransactionScope objects and the underlying connection lifecycle in .NET applications. It can also surface when MSDTC (Microsoft Distributed Transaction Coordinator) is misconfigured or the security context between SQL Server 2025 and the client does not permit transaction propagation.

Step-by-Step Resolution Guide

Step 1: Verify Local Transaction Context in Application Code

  • Confirm that a BEGIN TRANSACTION or an active TransactionScope exists before any operation that triggers promotion (e.g., opening a second connection within the same scope).
  • Review ORM or driver code (ADO.NET, JDBC, ODBC) to ensure the connection isn’t closed or returned to the pool before the transaction is promoted.
  • Check for asynchronous code paths where the transaction context may be lost across await calls.

Step 2: Validate and Restart MSDTC Service

  • Open services.msc on Windows Server 2025 / Windows 11 and confirm Distributed Transaction Coordinator is set to Automatic and is running.
  • Restart the service via PowerShell:
  Restart-Service -Name MSDTC -Force
  • Run dtcping or dcomcnfg.exe to validate DTC connectivity between the application server and the SQL Server instance.

Step 3: Reconfigure MSDTC Security Settings

  • Open dcomcnfg.exe → Component Services → Computers → My Computer → Distributed Transaction Coordinator → Local DTC → Properties → Security tab.
  • Enable Network DTC Access, Allow Inbound/Outbound, and set authentication to Mutual Authentication Required (or No Authentication Required only in trusted internal networks).
  • Apply changes and restart the MSDTC service for the settings to take effect.

Step 4: Check SQL Server Configuration and Firewall Rules

  • Confirm TCP port 135 (RPC) and the dynamic DTC port range are open between the application server and SQL Server 2025 host.
  • Use sys.dm_tran_active_transactions and sys.dm_tran_session_transactions DMVs on SQL Server to confirm no orphaned sessions are interfering with transaction state.
  • Ensure the SQL Server service account has the necessary rights to interact with MSDTC (Log on as a service and DCOM launch permissions).

Alternative or Verification Steps

  • Re-run the failing transaction after restarting MSDTC and confirm success by checking Event Viewer → Applications and Services Logs → MSDTC for clean promotion events (no Event ID 3965 recurrence).
  • If the issue persists, bypass automatic promotion by explicitly using a single connection and local transaction (SqlTransaction instead of TransactionScope spanning multiple connections) to avoid unnecessary escalation to a distributed transaction.

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

Troubleshooting Guide: Error 3966 – Transaction Rolled Back Due to Version Store Shrinkage

Why This Error Happens

Error 3966 occurs when tempdb runs out of available space, forcing SQL Server to shrink the version store that supports Snapshot Isolation or Read Committed Snapshot Isolation (RCSI). Any long-running transaction that still required an old row version for consistency is marked as a “victim” and subsequently rolled back once it attempts to access that now-purged version. This is fundamentally a resource-pressure issue in tempdb, often caused by undersized tempdb files, long-running transactions holding versions open, or heavy concurrent workloads generating excessive row versioning data.

Step-by-Step Resolution Guide

Step 1: Increase and Pre-Size tempdb Capacity

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Navigate to Server Properties > Database Settings, or run a T-SQL script to modify tempdb file sizes:
  ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, SIZE = 10240MB, FILEGROWTH = 1024MB);
  • Ensure tempdb data files reside on a fast, dedicated drive (ideally NVMe/SSD) separate from OS and user databases on Windows Server 2025.
  • Restart the SQL Server service for file size changes to take effect if autogrowth events were previously exhausting disk space.

Step 2: Identify and Terminate Long-Running Transactions

  • Run the following query to find transactions holding open snapshots:
  SELECT session_id, elapsed_time_seconds, database_id 
  FROM sys.dm_tran_active_snapshot_database_transactions
  ORDER BY elapsed_time_seconds DESC;
  • Correlate session_id with sys.dm_exec_requests to identify the offending application or query.
  • Work with application owners to shorten transaction scope, or manually kill the session using KILL <session_id> if it is safe to do so.

Step 3: Monitor and Adjust tempdb Version Store Usage

  • Enable monitoring via Performance Monitor (PerfMon) on Windows Server 2025, tracking the SQLServer:Transactions > Version Store Size (KB) counter.
  • Query sys.dm_tran_version_store_space_usage to identify which database is consuming the most version store space:
  SELECT database_id, reserved_page_count * 8 AS space_kb 
  FROM sys.dm_tran_version_store_space_usage;
  • If a single database is disproportionately responsible, consider isolating heavy RCSI/Snapshot workloads to a dedicated instance or adjusting isolation levels where strict snapshot consistency is not required.

Step 4: Add Multiple tempdb Data Files

  • Configure tempdb with multiple equally-sized data files (typically matching the number of logical CPU cores, up to 8) to reduce allocation contention that can exacerbate space pressure.
  • Example command to add a secondary file:
  ALTER DATABASE tempdb ADD FILE (NAME = tempdev2, FILENAME = 'D:\TempDB\tempdev2.ndf', SIZE = 10240MB, FILEGROWTH = 1024MB);
  • Verify file layout using sys.master_files to confirm even distribution.

Alternative or Verification Steps

  • Verify the fix: Re-run the previously failing workload during peak concurrency and monitor sys.dm_tran_version_store_space_usage to confirm tempdb no longer approaches capacity limits (check free space via sys.dm_os_volume_stats).
  • Alternative solution: If space constraints persist despite tuning, temporarily disable Snapshot Isolation/RCSI on the affected database (ALTER DATABASE [DBName] SET ALLOW_SNAPSHOT_ISOLATION OFF;) to stop version generation while you address the underlying storage capacity on Windows Server 2025.

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.

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

Troubleshooting Guide: Error 3963 – Distributed Transactions Not Supported Under Snapshot Isolation

Why This Error Happens

This error occurs because SQL Server 2025 does not permit a session to enlist in a distributed transaction (via MSDTC) while the connection or database is operating under SNAPSHOT or READCOMMITTEDSNAPSHOT isolation level for that transactional scope. The engine detects a conflict between the versioning-based concurrency model of snapshot isolation and the two-phase commit protocol required by distributed transactions, and it aborts the transaction to prevent data inconsistency. This typically surfaces when an application explicitly sets SET TRANSACTION ISOLATION LEVEL SNAPSHOT before calling BEGIN DISTRIBUTED TRANSACTION, or when linked server queries implicitly promote a local transaction to a distributed one while snapshot isolation is active.

Step-by-Step Resolution Guide

Step 1: Identify the Isolation Level Causing the Conflict

  • Check the application or stored procedure code for SET TRANSACTION ISOLATION LEVEL SNAPSHOT statements preceding distributed transaction calls.
  • Run the following query to confirm the database’s default isolation settings:
  SELECT name, snapshot_isolation_state_desc, is_read_committed_snapshot_on 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • Review Event Viewer (Windows Logs > Application) on Windows Server 2025 for correlating Event ID 3963 entries and the associated session/query details.

Step 2: Modify the Transaction Isolation Level

  • Change the isolation level to READ COMMITTED or SERIALIZABLE immediately before initiating the distributed transaction block:
  SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
  BEGIN DISTRIBUTED TRANSACTION;
  • If the application relies on row-versioning for reads, isolate the snapshot logic into a separate local transaction that completes before the distributed transaction begins.

Step 3: Reconfigure MSDTC and Database Options (if required)

  • Open Component Services on Windows Server 2025/Windows 11 (dcomcnfg.exe) and navigate to Component Services > Computers > My Computer > Distributed Transaction Coordinator > Local DTC.
  • Right-click Local DTC, select Properties, and ensure Network DTC Access is enabled under the Security tab if cross-server distributed transactions are required.
  • If READ_COMMITTED_SNAPSHOT is enabled at the database level and causing implicit conflicts, disable it for transactions requiring MSDTC:
  ALTER DATABASE YourDatabaseName SET READ_COMMITTED_SNAPSHOT OFF;
  • Restart the MSDTC service via services.msc to apply configuration changes.

Step 4: Refactor Application Logic to Avoid Mixed Transaction Models

  • Separate snapshot-isolated read operations from distributed write operations into distinct connection scopes.
  • Ensure linked server calls (OPENQUERY, four-part naming) that trigger automatic transaction promotion are wrapped in connections using READ COMMITTED isolation only.

Alternative or Verification Steps

  • Verify the fix by re-running the original transaction and confirming no Error 3963 appears in SQL Server Logs (EXEC sp_readerrorlog) or Event Viewer.
  • If the error persists, use SQL Server Profiler or Extended Events to trace the Error event and capture the exact SET TRANSACTION ISOLATION LEVEL state active at the moment BEGIN DISTRIBUTED TRANSACTION is called.

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

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_bindsession is 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 TRANSACTION or 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 sqlcmd to 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_bindsession calls, and temporarily disable them to isolate the root cause.

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

Troubleshooting Guide: Error 3961 – Snapshot Isolation Transaction Failed Due to Concurrent DDL Modification

Why This Error Happens

This error occurs when a transaction running under Snapshot Isolation (or RCSI) attempts to access an object whose metadata was altered by a concurrent DDL statement (such as ALTER TABLE, CREATE INDEX, or TRUNCATE TABLE) after the snapshot transaction began. SQL Server cannot guarantee a consistent, point-in-time view of the schema and data simultaneously, so it aborts the transaction to prevent reading mismatched metadata. This is commonly triggered by automated index maintenance jobs, schema migration scripts, or ORM-driven DDL changes running alongside long-lived reporting or ETL transactions.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting DDL Operation

  • Check SQL Server Agent job history and deployment logs for ALTER, DROP, CREATE INDEX, or TRUNCATE statements executed around the error timestamp.
  • Query sys.dm_exec_requests and sys.dm_tran_active_snapshot_database_transactions to correlate active snapshot transactions with concurrent schema changes.
  • Review Extended Events or the Default Trace (sys.traces) for DDL events captured during the failure window.

Step 2: Reschedule or Isolate DDL Maintenance Windows

  • Move index rebuilds, statistics updates, and schema migrations to low-traffic maintenance windows, ideally outside active reporting/ETL hours.
  • In SQL Server Management Studio (SSMS) 21, update SQL Agent job schedules under SQL Server Agent > Jobs > Properties > Schedules.
  • For CI/CD pipelines, add a pre-deployment check using sp_who2 or sys.dm_tran_active_transactions to confirm no long-running snapshot transactions are active before applying schema changes.

Step 3: Shorten Long-Running Snapshot Transactions

  • Break large reporting or ETL transactions into smaller batches with explicit COMMIT statements to reduce the exposure window.
  • Set a reasonable LOCK_TIMEOUT and avoid wrapping unrelated read operations inside a single open transaction.
  • Review application code (especially ORM-generated transactions) for unnecessarily held connections under SET TRANSACTION ISOLATION LEVEL SNAPSHOT.

Step 4: Adjust DDL Deployment Strategy for Online Changes

  • Where possible, use ONLINE = ON for index operations (ALTER INDEX ... REBUILD WITH (ONLINE = ON)) available in SQL Server 2025 Enterprise/Standard editions to minimize metadata locking conflicts.
  • For table alterations, consider using a blue-green schema deployment pattern (create new object, swap via sp_rename) instead of in-place ALTER TABLE during business hours.

Alternative or Verification Steps

  • After rescheduling, re-run the previously failing workload and monitor sys.dm_os_ring_buffers or the SQL Server Error Log for recurrence of Error 3961 over a full business cycle.
  • As a verification check, run SELECT * FROM sys.dm_tran_active_snapshot_database_transactions; during a scheduled DDL window to confirm no long-lived snapshot transactions overlap with the maintenance job.

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

Troubleshooting Guide: SQL Server Error 3959 – Version Store Full

Why This Error Happens

Error 3959 occurs when the version store in tempdb runs out of space because it fills up faster than SQL Server’s cleanup process can remove old row versions. This is typically caused by long-running active transactions that prevent version cleanup, an undersized or misconfigured tempdb, or a high volume of data modifications combined with Snapshot Isolation or Read Committed Snapshot Isolation (RCSI) being enabled on one or more databases. Essentially, tempdb cannot keep pace with the rate of versioned row generation, causing the version store to exceed available space and forcing SQL Server to reject new version entries.

Step-by-Step Resolution Guide

Step 1: Identify Long-Running or Orphaned Transactions

  • Run the following query to find transactions holding open the version store:
  SELECT * FROM sys.dm_tran_active_snapshot_database_transactions;
  • Look for transactions with a high elapsed_time_seconds value or a session_id that has been idle for an extended period.
  • Kill problematic sessions using KILL <session_id>; only after confirming they are safe to terminate.

Step 2: Resize and Reconfigure tempdb

  • Navigate to SQL Server Management Studio (SSMS) > Databases > System Databases > tempdb > Properties > Files.
  • Increase the initial size of tempdb data files (e.g., set to 4096 MB or higher depending on workload).
  • Ensure multiple tempdb data files are configured (ideally one per logical CPU core, up to 8) to reduce contention:
  ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, SIZE = 4096MB, FILEGROWTH = 512MB);
  • Place tempdb files on a dedicated, high-speed SSD volume (e.g., E:\SQLData\TempDB\) separate from user databases.

Step 3: Review and Adjust Isolation Level Usage

  • Check which databases have Snapshot Isolation or RCSI enabled:
  SELECT name, snapshot_isolation_state_desc, is_read_committed_snapshot_on 
  FROM sys.databases;
  • If not strictly required, consider disabling RCSI on non-critical databases to reduce version store pressure:
  ALTER DATABASE [YourDB] SET READ_COMMITTED_SNAPSHOT OFF;
  • Audit application code for transactions left open without a COMMIT or ROLLBACK.

Step 4: Monitor tempdb Version Store Usage

  • Use Performance Monitor (PerfMon) on Windows Server 2025 to track the Version Store Size (KB) counter under the SQLServer:Transactions object.
  • Set up an alert threshold (e.g., 80% of allocated tempdb space) to proactively catch future growth before it causes failures.

Step 5: Restart the SQL Server Service (If Version Store is Stuck)

  • If the version store remains full even after cleanup, perform a controlled restart via Services.msc or PowerShell:
  Restart-Service -Name 'MSSQLSERVER' -Force
  • This clears tempdb entirely, as it is recreated on every SQL Server startup.

Alternative or Verification Steps

  • Verify the fix by re-running SELECT * FROM sys.dm_tran_active_snapshot_database_transactions; and confirming the result set is empty or shows minimal active transactions with low elapsed time.
  • If the error persists under normal workload after resizing tempdb, consider isolating heavy batch/ETL jobs to run during off-peak hours, or review third-party applications (e.g., CDC, replication) that may hold long transactions open against the version store.

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

Troubleshooting Guide: Error 3960 – Snapshot Isolation Transaction Aborted Due to Update Conflict

Why This Error Happens

This error occurs when two or more concurrent transactions use snapshot isolation to read and then update the same row, and one transaction commits its changes before the other, causing SQL Server to detect a conflict and abort the later transaction to preserve data consistency. It is a core design behavior of snapshot isolation (not a bug), typically triggered by high-concurrency write patterns, long-running transactions holding stale row versions, or application logic that reads data under snapshot isolation and later attempts to update it without accounting for intervening changes. This can also surface more frequently if the tempdb version store is under pressure or if transaction scope/isolation levels are mismatched across application layers.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting Transactions and Queries

  • Query sys.dm_tran_active_snapshot_database_transactions to see active snapshot transactions.
  • Enable Extended Events or check SQL Server error logs for the exact table and session IDs involved.
  • Run SELECT * FROM sys.databases WHERE snapshot_isolation_state_desc = 'ON' to confirm which databases have snapshot isolation enabled.

Step 2: Review and Adjust Isolation Level Usage in Application Code

  • Check if the application explicitly sets SET TRANSACTION ISOLATION LEVEL SNAPSHOT before UPDATE statements on hot tables.
  • Replace snapshot isolation with READ COMMITTED SNAPSHOT for read-heavy operations, reserving true SNAPSHOT isolation only for reporting/read-only transactions.
  • Add retry logic (e.g., TRY...CATCH with exponential backoff) around UPDATE statements to gracefully handle Error 3960 when it occurs.

Step 3: Optimize Transaction Scope and Locking Strategy

  • Shorten transaction duration by committing changes as soon as possible instead of holding open transactions across multiple user interactions.
  • Use UPDLOCK or ROWLOCK hints on SELECT statements that precede an UPDATE within the same transaction to reduce conflict windows.
  • Review indexing on the affected table (e.g., in SSMS, right-click table > Properties > Indexes/Keys) to ensure UPDATE operations target narrow row sets efficiently.

Step 4: Monitor and Tune tempdb Version Store

  • Navigate to SQL Server Management Studio > Databases > tempdb > Properties > Files and confirm tempdb has adequate size and is split across multiple data files (ideally matching CPU core count up to 8).
  • Monitor version store usage via SELECT * FROM sys.dm_tran_version_store_space_usage.
  • Increase tempdb autogrowth settings or pre-size tempdb files to prevent version store bottlenecks under heavy snapshot isolation load.

Alternative or Verification Steps

  • To verify the fix, run a controlled concurrency test (two sessions updating the same row under snapshot isolation) and confirm no Error 3960 is thrown, or that retry logic successfully recovers the transaction.
  • If the error persists despite code changes, consider disabling snapshot isolation on the specific database (ALTER DATABASE [YourDB] SET ALLOW_SNAPSHOT_ISOLATION OFF) and switching to READ COMMITTED SNAPSHOT ISOLATION (RCSI) instead, which avoids update-conflict aborts entirely.

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

Troubleshooting Guide: Error 3958 — Transaction Aborted Accessing Versioned Row

Why This Error Happens

Error 3958 occurs when Row Versioning (used by Snapshot Isolation or Read Committed Snapshot Isolation) cannot locate a required version of a row in the version store within tempdb. This typically happens because tempdb has run out of space and was forced to shrink or clean up version store data prematurely, or because the version store cleanup process removed rows still needed by a long-running transaction. Insufficient tempdb sizing, long-running open transactions, or aggressive autogrowth limitations are the most common root causes.

Step-by-Step Resolution Guide

Step 1: Verify Tempdb Space and Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run EXEC sp_helpdb tempdb; to check current file sizes and growth settings.
  • Confirm tempdb data files are not set to a restrictive maximum size (MAXSIZE should ideally be set to “Unlimited” or a sufficiently large value).
  • Check physical disk space on the drive hosting tempdb files (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\).

Step 2: Identify Long-Running or Orphaned Transactions

  • Run the following query to find transactions holding open the version store:
  SELECT * FROM sys.dm_tran_active_snapshot_database_transactions;
  • Look for transactions with a high elapsed_time_seconds value or a low transaction_sequence_num that is blocking version store cleanup.
  • Kill or commit any stale sessions using KILL <session_id>; if they are confirmed to be orphaned or stuck.

Step 3: Resize and Optimize Tempdb Files

  • Increase the initial size of tempdb data files to prevent constant autogrowth events, which fragment disk space and slow down version store writes.
  • Navigate to SSMS > Databases > System Databases > tempdb > Properties > Files.
  • Set the Initial Size to a value based on your workload (e.g., 10240 MB) and set Autogrowth to a fixed MB increment (e.g., 1024 MB) rather than a percentage.
  • Restart the SQL Server service via services.msc on Windows Server 2025 for file size changes to take full effect if files were not already pre-sized.

Step 4: Move Tempdb to Faster/Larger Storage

  • If the current drive lacks sufficient space, move tempdb to a dedicated SSD volume with ample free space using the following T-SQL:
  ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, FILENAME = 'D:\SQLTemp\tempdb.mdf');
  • Restart the SQL Server (MSSQLSERVER) service for the path change to take effect.
  • Ensure the new drive has at least 2-3x the estimated workload requirement in free space.

Alternative or Verification Steps

  • To verify the fix, re-run the workload or query that triggered Error 3958 while monitoring sys.dm_db_file_space_usage to ensure the version store is not consuming 100% of available tempdb space.
  • If the error persists despite available space, check for Windows Server 2025 disk-level issues (such as Storage Spaces throttling) using the Resource Monitor or Perfmon counter % Disk Time on the tempdb volume.

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

Why This Error Happens

Error 3957 occurs when a transaction starts running under snapshot isolation before the ALLOW_SNAPSHOT_ISOLATION database option is turned ON, or when the option was toggled mid-session. SQL Server captures the isolation state of the database at the moment a transaction begins; if the setting changes afterward (or was never enabled), any snapshot-based read fails because the transaction’s version store context is invalid. This is typically caused by a misconfigured database option, a race condition during a schema/config deployment, or an application connecting before the DBA has finished enabling the feature.

Step-by-Step Resolution Guide

Step 1: Verify Current Snapshot Isolation Setting

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and connect to the SQL Server 2025 instance.
  • Run the following query to check the current state:
  SELECT name, snapshot_isolation_state_desc 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • If the result shows OFF, this confirms the root cause.

Step 2: Enable Snapshot Isolation on the Database

  • Ensure no active transactions are blocking the ALTER DATABASE command (snapshot changes require no other connections mid-transition).
  • Run the following T-SQL command with elevated permissions (sysadmin or db_owner role required):
  ALTER DATABASE YourDatabaseName 
  SET ALLOW_SNAPSHOT_ISOLATION ON;
  • On Windows Server 2025, confirm the SQL Server service account has the necessary file system permissions to write to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\ for tempdb version store growth, as snapshot isolation relies heavily on tempdb.

Step 3: Restart Application Connections Cleanly

  • Terminate and restart any application connection pools (IIS, .NET Core services, etc.) that initiated transactions before the setting was applied.
  • In IIS on Windows Server 2025, recycle the application pool via:
  iisreset /noforce
  • This ensures new connections pick up the updated isolation state rather than reusing stale pooled connections with the old transaction context.

Step 4: Check for Conflicting ALTER DATABASE Timing

  • Review deployment scripts or CI/CD pipelines (e.g., Azure DevOps, GitHub Actions) to ensure ALTER DATABASE ... SET ALLOW_SNAPSHOT_ISOLATION ON executes and fully commits before the application layer starts issuing queries.
  • Add a wait/poll step in deployment scripts checking sys.databases.snapshot_isolation_state equals 1 before proceeding.

Alternative or Verification Steps

  • To verify the fix, run a test transaction using SET TRANSACTION ISOLATION LEVEL SNAPSHOT; followed by a SELECT statement against the affected table — it should execute without raising Error 3957.
  • If the error persists under high concurrency, consider enabling READ_COMMITTED_SNAPSHOT instead (via ALTER DATABASE YourDatabaseName SET READ_COMMITTED_SNAPSHOT ON;) as it avoids explicit isolation-level timing conflicts for most standard application workloads.

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

Troubleshooting Guide: Error 3956 – Snapshot Isolation Transaction Failed to Start

Why This Error Happens

Error 3956 occurs because the ALTER DATABASE command used to enable ALLOW_SNAPSHOT_ISOLATION is an asynchronous operation that must wait for all existing active transactions in the database to commit before it can finalize the state change to ON. If a new transaction attempts to start a snapshot isolation level while the database is still in this “pending ON” transitional phase, SQL Server 2025 rejects it because the versioning infrastructure is not yet fully active. This is typically caused by long-running transactions or blocking sessions that were active at the exact moment the ALTER DATABASE command was issued, preventing the state transition from completing quickly.

Step-by-Step Resolution Guide

Step 1: Identify Blocking or Long-Running Transactions

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio connected to your Windows Server 2025 instance.
  • Run the following query to check the current state of snapshot isolation for the specific database:
  SELECT name, snapshot_isolation_state, snapshot_isolation_state_desc 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • Look for a snapshot_isolation_state value of 2 (INTRANSITIONTO_ON), which confirms the pending status.

Step 2: Locate and Terminate Blocking Sessions

  • Query sys.dm_tran_active_transactions and sys.dm_exec_sessions to find any open transactions preventing the version store from initializing.
  • Use the following command to check for active requests against the specific database ID:
  SELECT * FROM sys.dm_exec_requests WHERE database_id = DB_ID('YourDatabaseName');
  • If a specific Session ID (SPID) is holding an old transaction open (common with ORM tools like Entity Framework or legacy JDBC drivers), terminate it using KILL [SPID].

Step 3: Wait for Transition or Restart the Alter Command

  • Allow a grace period of 30–60 seconds after killing blocking processes, as the background mechanism needs time to loop through and verify the Transaction Log Sequence Number (LSN).
  • If the state remains stuck, re-issue the command manually via a new query window to force a re-check (ensure no other session is currently running this same command):
  ALTER DATABASE YourDatabaseName SET ALLOW_SNAPSHOT_ISOLATION ON;
  • Check the SQL Server Error Log via SQL Server Configuration Manager > Logs for any underlying I/O or Tempdb contention errors that might be stalling the version store creation on the Windows Server 2025 host.

Step 4: Verify Tempdb Health and Capacity

  • Navigate to the Tempdb file location (default: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA) to ensure there is sufficient disk space.
  • Since snapshot isolation relies heavily on the version store located in Tempdb, verify that Tempdb has not reached its maximum size limit, as this will stall the ALTER DATABASE transition indefinitely.
  • Expand Tempdb files manually if necessary using ALTER DATABASE tempdb MODIFY FILE.

Alternative or Verification Steps

  • Verification: Re-run the sys.databases query from Step 1; a successful fix will show snapshot_isolation_state_desc as ON rather than IN_TRANSITION_TO_ON.
  • Alternative: If the issue persists due to a stuck system process, consider scheduling the ALTER DATABASE command during a maintenance window with SINGLE_USER mode to guarantee no conflicting transactions block the state change.

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

Troubleshooting Guide: Error 3955 – Snapshot Isolation Transaction Failed Due to Skipped Recovery

Why This Error Happens

This error occurs when a database was brought online using the WITH STANDBY or WITH NORECOVERY option, or when recovery was explicitly bypassed during a restore sequence, leaving the database in a state where transaction log rollback/roll-forward operations were never completed. Snapshot isolation relies on the version store and a fully recovered transaction log to generate consistent row versions, so SQL Server 2025 blocks any snapshot-isolation transaction until standard recovery has fully run. This typically surfaces after log shipping configurations, manual restore scripts, or read-only standby scenarios where the database is intentionally kept in a “recovering” or “standby” state but application connections still attempt snapshot-isolated reads or writes.

Step-by-Step Resolution Guide

Step 1: Verify the Current Database State

  • Open SQL Server Management Studio (SSMS) or a query window and run:
  SELECT name, state_desc, is_read_committed_snapshot_on, snapshot_isolation_state_desc
  FROM sys.databases
  WHERE name = 'YourDatabaseName';
  • Confirm whether state_desc returns RESTORING, STANDBY, or RECOVERY_PENDING instead of ONLINE.
  • Check the SQL Server Error Log (default path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related restore or recovery entries.

Step 2: Complete the Database Recovery Process

  • If the database is part of a restore sequence (e.g., log shipping or manual differential restores), issue the final restore command WITH RECOVERY to finish the rollback phase:
  RESTORE DATABASE YourDatabaseName WITH RECOVERY;
  • If the database was left in STANDBY mode intentionally for read-only reporting, be aware that snapshot isolation transactions cannot run against it until it is fully recovered — switch to WITH RECOVERY if write/snapshot access is required.
  • Ensure no additional transaction log backups are pending application before recovery is finalized.

Step 3: Validate Snapshot Isolation Settings Post-Recovery

  • Once the database shows ONLINE in sys.databases, re-enable or confirm snapshot isolation settings:
  ALTER DATABASE YourDatabaseName SET ALLOW_SNAPSHOT_ISOLATION ON;
  ALTER DATABASE YourDatabaseName SET READ_COMMITTED_SNAPSHOT ON;
  • Restart the SQL Server service via services.msc on Windows Server 2025 / Windows 11 if the setting change does not apply immediately.
  • Re-run the application transaction that originally triggered Error 3955 to confirm resolution.

Step 4: Check for Underlying Storage or Corruption Issues

  • If recovery repeatedly fails to complete, run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORRESULTS; to rule out corrupted data or log files.
  • Inspect the underlying disk/volume (especially on Storage Spaces Direct or virtualized Windows Server 2025 hosts) for I/O errors in Windows Event Viewer under Windows Logs > System.

Alternative or Verification Steps

  • Confirm the fix by querying sys.databases again and verifying state_desc = ONLINE and snapshot_isolation_state_desc = ON, then execute a test transaction using SET TRANSACTION ISOLATION LEVEL SNAPSHOT;.
  • If recovery cannot complete due to a damaged log file, restore the database from the last known good full backup plus available log backups to a new database name, then redirect the application connection string as a temporary workaround.

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

Troubleshooting Guide: SQL Server Error 3953 (Snapshot Isolation Transaction Failed)

Why This Error Happens

This error occurs when a transaction using snapshot isolation attempts to access a database that is still in the process of recovery (crash recovery, mirroring failover, or Always On secondary redo) and has not yet completed the rollback/roll-forward phase required to generate a consistent version store. Because the version store relies on a fully recovered database state to track row versions in tempdb, SQL Server blocks the request rather than risk returning inconsistent data. This is most commonly seen immediately after a failover, a service restart, or during a lengthy crash recovery on a large database with heavy transaction log activity.

Step-by-Step Resolution Guide

Step 1: Confirm the Database Recovery State

  • Open SQL Server Management Studio (SSMS) or run a query against the instance.
  • Execute: SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabaseName';
  • Look for states such as RECOVERING, RECOVERY_PENDING, or SUSPECT instead of ONLINE.

Step 2: Monitor Recovery Progress in the Error Log

  • Open the SQL Server Error Log via SSMS (Management > SQL Server Logs) or navigate to the log file directly, typically located at:
    C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG
  • Look for messages like Recovery of database 'YourDatabaseName' (X percent complete).
  • If recovery is progressing normally, allow the process to finish before retrying transactions; do not attempt a forced restart.

Step 3: Check for Long-Running Transactions or Large Log Files

  • Run: DBCC SQLPERF(LOGSPACE); to check the transaction log size and usage percentage for the affected database.
  • If the log file is abnormally large (several GBs with high usage), the redo/undo phase of recovery will take longer.
  • Consider increasing tempdb file sizes proactively if the version store is a bottleneck, located under:
    Instance > Databases > tempdb > Properties > Files in SSMS.

Step 4: Retry the Application Logic with a Backoff Mechanism

  • Modify the application or script layer to catch Error 3953 and implement a retry-with-delay pattern (e.g., wait 10-30 seconds before resubmitting the transaction).
  • Example T-SQL retry wrapper:
  BEGIN TRY
      SET TRANSACTION ISOLATION LEVEL SNAPSHOT;
      BEGIN TRAN;
      -- your query here
      COMMIT;
  END TRY
  BEGIN CATCH
      IF ERROR_NUMBER() = 3953
          WAITFOR DELAY '00:00:10';
      -- Re-attempt logic here
  END CATCH;

Step 5: Validate AlwaysOn/Mirroring Configuration (If Applicable)

  • If the database is part of an Always On Availability Group, check the secondary replica’s synchronization state via:
    SELECT synchronization_state_desc FROM sys.dm_hadr_database_replica_states;
  • Ensure the secondary has fully applied the redo queue before allowing read-only snapshot isolation queries to route to it.

Alternative or Verification Steps

  • Once sys.databases shows the state_desc as ONLINE, rerun the failed transaction manually in SSMS to confirm Error 3953 no longer appears.
  • If the error persists after recovery completes, check for database corruption by running DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORS; to rule out underlying data file integrity issues.

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

Troubleshooting Guide: Error 3954 – Snapshot Isolation Transaction Failed to Start

Why This Error Happens

This error occurs when an ALTER DATABASE SET ALLOW_SNAPSHOT_ISOLATION OFF command is issued while there are still active transactions using snapshot isolation in the database, putting the database into a transitional “disabling” state. SQL Server 2025 blocks any new snapshot transactions from starting during this transition to maintain consistency, causing the client request to fail until the ALTER DATABASE operation fully completes. This typically happens in high-concurrency environments where a DBA attempts to toggle isolation settings without first draining existing long-running sessions.

Step-by-Step Resolution Guide

Step 1: Identify Active Snapshot Transactions

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio connected to your SQL Server 2025 instance.
  • Run the following query to find sessions currently using snapshot isolation:
SELECT session_id, transaction_id, is_snapshot 
FROM sys.dm_tran_active_snapshot_database_transactions;
  • Note the session_id values returned, as these are blocking the state transition.

Step 2: Terminate or Wait Out Blocking Sessions

  • If the sessions are safe to terminate, kill them using KILL <session_id>; in a new query window.
  • Alternatively, wait for long-running transactions to commit naturally if killing them risks data integrity issues.
  • Monitor the transition status using:
SELECT name, snapshot_isolation_state_desc 
FROM sys.databases 
WHERE name = 'YourDatabaseName';
  • Confirm the state moves from IN_TRANSITION_TO_OFF to OFF.

Step 3: Re-run the ALTER DATABASE Command

  • Once all blocking sessions have cleared, re-issue the command:
ALTER DATABASE YourDatabaseName 
SET ALLOW_SNAPSHOT_ISOLATION OFF;
  • Ensure no new snapshot transactions start during this window by temporarily restricting application connections if possible (e.g., via ALTER DATABASE ... SET SINGLE_USER for critical maintenance windows).

Step 4: Adjust Application Retry Logic

  • Update application connection strings or ORM configurations (Entity Framework, Dapper, etc.) to implement a retry policy for Error 3954.
  • Set a reasonable backoff interval (e.g., 2-5 seconds) to allow the transition to complete before retrying the snapshot transaction.

Alternative or Verification Steps

  • Verify the Fix: Query sys.databases for the target database and confirm snapshot_isolation_state_desc returns ON or OFF (not IN_TRANSITION) before resuming full application traffic.
  • Alternative Solution: If the transition hangs indefinitely due to an orphaned session, restart the SQL Server service during a maintenance window via services.msc on Windows Server 2025 to forcibly clear the transaction state, though this should be a last resort due to downtime implications.

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

Troubleshooting Guide: Error 3952 – Snapshot Isolation Not Allowed

Why This Error Happens

This error occurs because the ALLOW_SNAPSHOT_ISOLATION database option is set to OFF at the database level, which is the default configuration for most databases in SQL Server 2025. When a transaction explicitly requests the SNAPSHOT isolation level, SQL Server checks this database-level flag before allowing the transaction to proceed, and rejects it if the flag has not been enabled. This is not a permissions or connectivity issue, but rather a missing configuration setting that must be explicitly turned on by a database administrator.

Step-by-Step Resolution Guide

Step 1: Verify the Current Database Setting

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and connect to your SQL Server 2025 instance.
  • Run the following query to check the current state of the flag:
  SELECT name, snapshot_isolation_state_desc 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • If the result shows OFF, this confirms the root cause of Error 3952.

Step 2: Enable Snapshot Isolation via ALTER DATABASE

  • Ensure no active transactions are blocking the schema change (this command requires a brief lock).
  • Execute the following T-SQL command, replacing YourDatabaseName with your target database:
  ALTER DATABASE YourDatabaseName 
  SET ALLOW_SNAPSHOT_ISOLATION ON;
  • Note: Unlike READ_COMMITTED_SNAPSHOT, this specific option does not require exclusive database access and can typically be run while users are connected.

Step 3: Update Application Connection Logic

  • Open your application’s data access layer or stored procedure code.
  • Ensure the transaction logic explicitly sets the isolation level before executing queries:
  SET TRANSACTION ISOLATION LEVEL SNAPSHOT;
  BEGIN TRANSACTION;
  -- Your SELECT/INSERT/UPDATE logic here
  COMMIT TRANSACTION;
  • Save and redeploy the application or restart the specific service consuming the database connection.

Step 4: Restart Dependent Services (If Applicable)

  • If running on Windows Server 2025, open Services.msc.
  • Restart the SQL Server (MSSQLSERVER) service or the specific named instance service to clear any cached connection pooling states that might still be rejecting the old isolation level.
  • Re-run the failing application transaction to confirm the error is cleared.

Alternative or Verification Steps

  • Verification: Re-run the sys.databases query from Step 1; the snapshot_isolation_state_desc column should now return ON.
  • Alternative Fix: If application code cannot be modified to use SNAPSHOT explicitly, consider enabling READ_COMMITTED_SNAPSHOT instead (ALTER DATABASE YourDatabaseName SET READ_COMMITTED_SNAPSHOT ON;), which applies row-versioning automatically to the default READ COMMITTED isolation level without requiring code changes, though this requires exclusive database access to execute.

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

Troubleshooting Guide: SQL Server Error 3951 – Snapshot Isolation Mismatch

Why This Error Happens

This error occurs because a transaction was initiated under a standard isolation level (such as READ COMMITTED or REPEATABLE READ), but a statement within that same transaction attempted to execute using SNAPSHOT isolation. SQL Server 2025 does not allow the isolation level of an active transaction to be switched to SNAPSHOT mid-execution; the SET TRANSACTION ISOLATION LEVEL SNAPSHOT command must be issued before the BEGIN TRANSACTION statement. This is typically caused by application connection pooling reusing a session where isolation levels were not reset, or by stored procedures that assume a specific isolation context that the calling application does not honor.

Step-by-Step Resolution Guide

Step 1: Audit the Transaction Code Order

  • Locate the specific stored procedure or application code block referenced in the error’s database name (%.*ls).
  • Verify that SET TRANSACTION ISOLATION LEVEL SNAPSHOT; is placed strictly before the BEGIN TRAN keyword in the T-SQL script.
  • Check for any nested transactions where an outer transaction might have already started with a different isolation level.

Step 2: Enable Database-Level Snapshot Support

  • Confirm that the target database actually has the snapshot isolation framework enabled, as a disabled setting can sometimes cause conflicting session behaviors.
  • Run the following query in SQL Server Management Studio (SSMS) to check the status:
  SELECT name, snapshot_isolation_state_desc 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • If the result shows OFF, enable it using: ALTER DATABASE YourDatabaseName SET ALLOW_SNAPSHOT_ISOLATION ON;

Step 3: Reset Connection Pooling Isolation Levels

  • Since connection pooling in IIS or .NET applications reuses sessions, ensure the application explicitly resets the isolation level at the start of every new logical transaction rather than relying on the default state of a pooled connection.
  • In your connection string (for .NET apps), ensure Enlist=false is set if you are manually managing distributed transactions to avoid ambient transaction scope conflicts.
  • Restart the IIS Application Pool or Windows Service via Server Manager on Windows Server 2025 to clear any hung sessions holding an incorrect isolation state.

Step 4: Isolate the Specific Query Batch

  • Use SQL Server Profiler or Extended Events (XEvents) to trace the exact batch text that triggers Error 3951.
  • Filter the trace by the Error event class with Error number 3951 to capture the exact T-SQL statement causing the mismatch.
  • Modify the specific query to run in a separate, dedicated transaction scope rather than inheriting the parent transaction’s isolation level.

Alternative or Verification Steps

  • Verification: Re-run the failed transaction after modifying the code order; check the SQL Server Error Log (via SSMS > Management > SQL Server Logs) to confirm Error 3951 no longer appears for that session ID.
  • Alternative: If modifying the application code is not immediately feasible, set the database’s default isolation level using a Resource Governor workload group to force READCOMMITTEDSNAPSHOT ON at the database level, which handles row versioning without requiring an explicit mid-transaction isolation switch.