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

Troubleshooting Guide: SQL Server Error 8031 (TDS RPC Protocol Stream / Table-Valued Parameter Error)

Why This Error Happens

This error occurs when the client application sends a malformed or inconsistent data stream for a Table-Valued Parameter (TVP), typically due to a mismatch between the column metadata declared in the TVP structure and the actual data rows being transmitted. It is frequently caused by outdated or corrupted client drivers (ODBC/OLE DB/SqlClient) that incorrectly serialize the TDS packets, or by a mismatch between the User-Defined Table Type schema on the server and the DataTable schema in the application code. Network packet corruption or truncation during transmission can also trigger this specific protocol violation.

Step-by-Step Resolution Guide

Step 1: Verify Client Driver Compatibility

  • Check the version of the Microsoft OLE DB Driver or SqlClient library used by the application connecting to SQL Server 2025.
  • Navigate to Control Panel > Programs > Programs and Features on the Windows Server 2025 host to check installed driver versions.
  • Update to the latest Microsoft ODBC Driver 18+ or Microsoft.Data.SqlClient NuGet package, as older drivers often lack full support for newer TVP structures.

Step 2: Validate the Table-Valued Parameter Schema

  • Run a query against sys.table_types in SQL Server Management Studio (SSMS) to compare the defined schema against the application’s object structure.
  • Ensure the order of columns in the application’s DataTable or SqlDataRecord object exactly matches the order defined in the CREATE TYPE statement.
  • Check for NULL values being passed into columns that are explicitly defined as NOT NULL within the table type definition.

Step 3: Inspect Network Packet Size Configuration

  • Open SQL Server Configuration Manager and navigate to SQL Server Network Configuration > Protocols.
  • Verify that the Packet Size setting in the connection string (usually default 4096 bytes) is sufficient for large TVP batches; try increasing this to 8192 if large datasets are being passed.
  • Restart the SQL Server service via services.msc to apply any configuration changes made in the Configuration Manager.

Step 4: Capture and Analyze the TDS Stream

  • Use SQL Server Profiler or Extended Events to capture the RPC:Starting and RPC:Completed events during the failure.
  • Filter the trace specifically for the Error and TextData columns to view the exact table parameter name mentioned in the error (%.*ls).
  • Look for discrepancies in data types (e.g., sending an int where a bigint is expected) within the captured XML/binary stream.

Alternative or Verification Steps

  • Verification: Execute the stored procedure manually in SSMS using a hardcoded DECLARE @TVP variable with sample data to confirm the server-side logic works independent of the application.
  • Alternative Fix: If the error persists only with a specific application, bypass the TVP entirely by serializing the data into a JSON string and using the native OPENJSON function in SQL Server 2025 to parse the data on the server side instead.

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

Troubleshooting Guide: SQL Server Error 8029 (TDS/RPC Protocol Stream Incorrect)

Why This Error Happens

Error 8029 occurs when the client application sends a malformed TDS (Tabular Data Stream) packet for a table-valued parameter (TVP), usually because the column metadata defined in the client-side DataTable or SqlDataRecord does not match the structure of the user-defined table type registered on SQL Server 2025. This mismatch is often caused by a schema drift after a table type was altered, a mismatched driver version (e.g., an outdated ODBC/OLE DB driver on Windows 11 or Windows Server 2025), or data corruption introduced when serializing the TVP rows. It can also result from an application sending columns in the wrong order, since TDS RPC calls for TVPs are strictly positional rather than name-based.

Step-by-Step Resolution Guide

Step 1: Verify the Table-Valued Parameter Schema

  • Run sp_help 'YourTableTypeName' in SQL Server Management Studio (SSMS) to confirm the exact column order, data types, and nullability of the registered type.
  • Compare this output line-by-line against the client-side DataTable/SqlDataRecord definition in your application code.
  • Ensure no columns were added/removed on the SQL side without updating the application (common after a schema migration).

Step 2: Update and Validate Client Drivers

  • Open Settings > Apps > Installed Apps on Windows 11/Server 2025 and check the version of “Microsoft OLE DB Driver for SQL Server” or “ODBC Driver for SQL Server.”
  • Download and install the latest driver matching SQL Server 2025 compatibility from the official Microsoft Download Center.
  • Restart the application pool (IIS) or application service after the driver update using:
  iisreset

Step 3: Capture and Inspect the TDS Stream

  • Use SQL Server Profiler or Extended Events to capture the RPC:Starting and RPC:Completed events filtered on the problematic stored procedure.
  • Check the Windows Event Viewer (Applications and Services Logs > MSSQLSERVER) for correlated Error 8029 entries with timestamps matching the failed call.
  • Identify whether the byte stream shows truncated or reordered columns, confirming a mismatch in the TVP structure sent versus expected.

Step 4: Rebuild and Re-register the Table Type

  • If the table type was altered improperly, drop and recreate it cleanly:
  DROP TYPE dbo.YourTableTypeName;
  CREATE TYPE dbo.YourTableTypeName AS TABLE
  (
      Column1 INT,
      Column2 NVARCHAR(100)
  );
  • Redeploy the stored procedure that consumes this type to ensure the compiled plan references the updated structure.
  • Restart the SQL Server service via Services.msc (SQL Server (MSSQLSERVER)) to clear any cached execution plans referencing the old type.

Alternative or Verification Steps

  • Re-run the failing transaction from the application and confirm no Error 8029 appears in SSMS or the Windows Event Log.
  • If the issue persists, isolate the problem by testing the same TVP call directly from SSMS using a DECLARE @TVP variable populated with INSERT INTO, bypassing the application layer to confirm whether the fault lies in the client serialization code.

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

Troubleshooting Guide: SQL Server Error 8030 – TDS RPC Protocol Stream Error (Table-Valued Parameter)

Why This Error Happens

Error 8030 occurs when the Tabular Data Stream (TDS) sent by the client application does not match the structure that SQL Server 2025 expects for a Table-Valued Parameter (TVP). This typically happens when the client-defined table type (columns, data types, or ordinal positions) is out of sync with the user-defined table type stored in the database, often due to a schema change, a mismatched driver version, or a stale metadata cache on the client side. It can also occur when the application passes a DataTable, DbDataReader, or IEnumerable<SqlDataRecord> object whose column order or nullability does not exactly align with the server-side type definition.

Step-by-Step Resolution Guide

Step 1: Verify the Table Type Definition on the Server

  • Connect to the instance using SSMS and run SELECT * FROM sys.table_types WHERE name = 'YourTableTypeName'; to confirm the type exists and check its system_type_id mappings.
  • Expand Programmability > Types > User-Defined Table Types in Object Explorer and compare columns, order, and nullability against what the client expects.
  • Check for any recent ALTER or DROP/CREATE operations on the table type that may not have been propagated to the client.

Step 2: Synchronize the Client-Side Schema Definition

  • In .NET applications, ensure the DataTable or List<SqlDataRecord> columns are added in the exact same order as the SQL table type definition.
  • For SqlDataRecord, verify the SqlMetaData array matches data types and lengths precisely (e.g., NVARCHAR(50) vs NVARCHAR(MAX) mismatches commonly trigger this error).
  • Update to the latest Microsoft.Data.SqlClient NuGet package to rule out legacy driver bugs with TVP serialization.

Step 3: Clear Cached Execution Plans and Metadata

  • Run DBCC FREEPROCCACHE; on the Windows Server 2025 instance to purge stale cached plans referencing the old table type structure.
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER in PowerShell (run as Administrator) if caching persists after the plan flush.
  • If using connection pooling, restart the application pool (IIS) or application service on Windows 11/Server 2025 to force a fresh connection handshake.

Step 4: Inspect Network and Driver Compatibility

  • Confirm the client driver (ODBC, OLE DB, or Microsoft.Data.SqlClient) version is certified for SQL Server 2025; older TDS 7.x drivers may not fully support newer TVP extensions.
  • Check C:\Program Files\Microsoft SQL Server\160\...\Log\ERRORLOG for additional context flagged alongside Error 8030.
  • Use SQL Server Profiler or Extended Events to capture the exact RPC call and compare the parameter payload against the expected schema.

Alternative or Verification Steps

  • After applying fixes, re-run the failing stored procedure call from the application and confirm no 8030 error appears in the ERRORLOG or application logs.
  • If the issue persists, drop and recreate the table type using DROP TYPE and CREATE TYPE, then redeploy the application’s data access layer to force a full metadata refresh.

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

Troubleshooting Guide: SQL Server Error 8028 (Invalid TDS RPC Parameter Length)

Why This Error Happens

This error occurs when the TDS (Tabular Data Stream) protocol stream sent by a client application contains a parameter whose declared length does not match the data type’s expected boundaries, often due to a mismatched client driver version against SQL Server 2025. It is commonly triggered by outdated ODBC/OLE DB drivers, corrupted connection buffers, or application code that incorrectly calculates variable-length field sizes (such as VARCHAR(MAX), VARBINARY, or NVARCHAR parameters) before sending the RPC call. Occasionally, this is also caused by a mismatch between 32-bit and 64-bit client libraries communicating with the 64-bit SQL Server 2025 engine on Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify and Update Client Drivers

  • Check the version of the ODBC Driver or OLE DB Provider used by the connecting application (e.g., “ODBC Driver 18 for SQL Server”).
  • Navigate to Control Panel > Programs and Features on Windows 11/Server 2025 to confirm the installed driver version.
  • Download and install the latest Microsoft ODBC Driver compatible with SQL Server 2025 from the official Microsoft Download Center.
  • Restart the application service after the driver update to ensure the new library is loaded.

Step 2: Inspect the Application Query Parameters

  • Open the application’s data access layer code (ADO.NET, JDBC, or ODBC) and locate the specific stored procedure call referenced in the error message.
  • Check for hard-coded parameter lengths that might be shorter than the actual data being passed (e.g., defining a parameter as VARCHAR(50) while sending a 100-character string).
  • Use SQL Server Profiler or Extended Events to capture the exact RPC:Starting event and review the parameter payload for truncation or size mismatches.

Step 3: Validate Network Packet Size Configuration

  • Open SQL Server Management Studio (SSMS) and right-click the server instance, then select Properties > Connections.
  • Check the Network Packet Size setting; ensure it is not set to a non-standard value (default is 4096 bytes) that might be fragmenting large parameter streams incorrectly.
  • If using a custom packet size, revert it to the default or increase it to accommodate large object (LOB) data types.

Step 4: Repair Corrupted Client-Side Cache

  • On the client machine running Windows 11, clear the DNS and connection cache using ipconfig /flushdns in an elevated Command Prompt.
  • Restart the “SQL Server Browser” service via Services.msc if you are using named instances to ensure connection metadata is refreshed.
  • Re-attempt the connection to see if the stale TDS handshake data was the root cause.

Alternative or Verification Steps

  • To verify the fix, run the specific stored procedure directly in SSMS with the exact parameter values used by the application; if it executes successfully, the issue is isolated to the client-side driver or code logic.
  • If the error persists, use SQL Server Profiler to trace the RPC:Completed event and compare the “Binary Data” column length against the table schema’s defined column length to pinpoint the exact mismatched field.

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

Troubleshooting Guide: SQL Server Error 8027 – Invalid CLR Type Schema in TDS RPC Stream

Why This Error Happens

This error occurs when a client application sends a Remote Procedure Call (RPC) to SQL Server 2025 using a CLR-based parameter (such as a User-Defined Type) whose schema information is either malformed, mismatched, or unregistered on the server side. This typically happens when the client-side assembly version of a User-Defined Type (UDT) does not match the version deployed in the SQL Server database, or when the TDS driver (ODBC/OLE DB/SqlClient) used by the application is outdated and incorrectly serializes the CLR metadata. Corrupted CLR assemblies within the master or user database can also trigger this schema validation failure.

Step-by-Step Resolution Guide

Step 1: Verify CLR Integration and Assembly Status

  • Connect to the instance via SQL Server Management Studio (SSMS) and run SELECT * FROM sys.assemblies; to check if the required CLR assembly is listed and valid.
  • Check if CLR is enabled by running sp_configure 'clr enabled';. If it returns 0, enable it using sp_configure 'clr enabled', 1; RECONFIGURE;.
  • Look for any assemblies with a NULL or corrupted hash value, which indicates a deployment failure.

Step 2: Update Client Drivers and Connection Libraries

  • Navigate to the application server and check the version of Microsoft.Data.SqlClient or the native msodbcsql driver being used.
  • Update the driver to the latest version compatible with SQL Server 2025 via the Microsoft Download Center or NuGet Package Manager.
  • Restart the application pool or service in IIS/Windows Services to ensure the new driver DLLs are loaded into memory.

Step 3: Re-deploy the CLR User-Defined Type

  • Drop the specific UDT and the associated assembly from the target database using DROP TYPE [dbo].[YourUDTName]; followed by DROP ASSEMBLY [YourAssemblyName];.
  • Re-compile the CLR project in Visual Studio to ensure the DLL matches the exact schema expected by the client application.
  • Re-deploy the assembly using CREATE ASSEMBLY [YourAssemblyName] FROM 'C:\Path\To\YourAssembly.dll' WITH PERMISSION_SET = SAFE;.

Step 4: Validate TDS Endpoint Configuration

  • Open SQL Server Configuration Manager on the Windows Server 2025 host.
  • Verify that the TCP/IP protocol settings under “SQL Server Network Configuration” have not been altered to use a non-standard TDS version that conflicts with the CLR schema definition.
  • Restart the SQL Server (MSSQLSERVER) service to apply any configuration changes.

Alternative or Verification Steps

  • To verify the fix, re-run the specific stored procedure or query that triggered the error using SSMS with the exact parameter values; if the RPC call executes without throwing Error 8027, the schema mismatch is resolved.
  • If the error persists, use SQL Server Profiler to capture the exact RPC:Starting event and compare the binary parameter schema against the assembly’s public key token to identify a potential assembly signing mismatch.

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

Troubleshooting Guide: SQL Server Error 8025 (TDS RPC Protocol Stream Error)

Why This Error Happens

Error 8025 occurs when the TDS (Tabular Data Stream) protocol stream sent by a client application contains an RPC call where a parameter is flagged with the “metadata unchanged” flag, but the parameter metadata does not actually match a previously cached definition. This typically happens due to a mismatched or outdated client driver (ODBC, OLE DB, or ADO.NET) that incorrectly reuses cached parameter metadata across executions with different schemas or data types. It can also be triggered by corrupted connection pooling states or a faulty custom application layer manually constructing TDS/RPC packets.

Step-by-Step Resolution Guide

Step 1: Update the Client Data Access Drivers

  • Verify the version of the driver used by the application (e.g., Microsoft OLE DB Driver for SQL Server, ODBC Driver 18, or SqlClient).
  • Download and install the latest driver compatible with SQL Server 2025 from the Microsoft Download Center.
  • On Windows 11/Server 2025, check installed versions via Control Panel > Programs and Features or run:
  Get-OdbcDriver | Where-Object {$_.Name -like "*SQL Server*"}

Step 2: Disable Connection Pooling Temporarily

  • Modify the application’s connection string to include Pooling=false to rule out stale pooled connections carrying invalid cached metadata.
  • For .NET applications, update the web.config or app.config connection string:
  Server=myServer;Database=myDB;Pooling=false;
  • Restart the application pool or service and reproduce the issue to confirm if pooling is the root cause.

Step 3: Clear Parameter Metadata Cache on SQL Server

  • Run the following T-SQL command to clear cached execution plans and associated parameter metadata:
  DBCC FREEPROCCACHE;
  • If using a specific database, isolate the cache clear:
  DBCC FLUSHPROCINDB (db_id('YourDatabaseName'));
  • Re-execute the failing stored procedure or RPC call to see if the error persists.

Step 4: Inspect and Rebuild the Stored Procedure/Parameters

  • Check if the stored procedure signature was recently altered (e.g., parameter data type changed from VARCHAR(50) to VARCHAR(100)) without updating the client-side parameter binding.
  • Use SQL Server Management Studio (SSMS) 21 to script out and re-validate the procedure definition:
  EXEC sp_helptext 'YourStoredProcedureName';
  • Ensure the application code passes parameters explicitly with matching SqlDbType and size definitions rather than relying on auto-detection.

Step 5: Capture a Network Trace for Deep Analysis

  • Use SQL Server Profiler or Extended Events to capture the RPC:Starting and RPC:Completed events to inspect the exact parameter payload causing the mismatch.
  • Filter the trace by the specific Application Name or Host Name generating the error.
  • Cross-reference the captured parameter list against the current schema definition in sys.parameters.

Alternative or Verification Steps

  • Verification: Re-run the application’s workload under load for 15-30 minutes while monitoring the Windows Event Viewer (Application Log) and SQL Server Error Log for the recurrence of Event ID 8025.
  • Alternative Fix: If the error persists after driver updates, revert the specific stored procedure to a previous schema version via source control, then reapply changes using sp_recompile 'YourStoredProcedureName' to force a fresh execution plan generation.

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

Troubleshooting Guide: SQL Server Error 8026 — TDS RPC Protocol Stream Metadata Mismatch

Why This Error Happens

This error occurs when a client application sends a Remote Procedure Call (RPC) to SQL Server 2025 with a parameter flagged as “metadata unchanged,” but the metadata signature for that parameter does not actually match what was cached from a previous call. This typically happens due to connection pooling conflicts, where a pooled connection reuses a prepared statement handle against a parameter whose data type, length, or precision has changed. It can also result from outdated or corrupted client drivers (such as ODBC, OLE DB, or ADO.NET) that mismanage the TDS packet structure when reusing cached execution plans.

Step-by-Step Resolution Guide

Step 1: Update and Verify Client Drivers

  • Ensure the application server (Windows Server 2025 / Windows 11) is using the latest Microsoft ODBC Driver or OLE DB Driver compatible with SQL Server 2025.
  • Navigate to Control Panel > Programs > Programs and Features to check currently installed driver versions.
  • Download the latest driver from the official Microsoft Learn documentation if the version is older than the last two release cycles.

Step 2: Disable Connection Pooling Temporarily (Isolation Test)

  • Open the application’s connection string configuration file (e.g., web.config, app.config, or a custom .ini file).
  • Add or modify the parameter: Pooling=False;
  • Restart the application pool via IIS Manager or restart the Windows Service hosting the application to force new connections without reused metadata handles.

Step 3: Clear the Procedure Cache on SQL Server

  • Open SQL Server Management Studio (SSMS) and connect to the target instance.
  • Execute the following command to clear cached execution plans that may hold stale parameter metadata:
DBCC FREEPROCCACHE;
  • If the issue is isolated to a specific stored procedure, use sp_recompile 'YourProcedureName' instead of a full cache flush to avoid performance degradation on production servers.

Step 4: Audit Application Code for Parameter Consistency

  • Review the application-layer code (C#, Java, or Python) handling the SqlCommand or PreparedStatement objects.
  • Check for logic that dynamically changes a parameter’s SqlDbType, size, or precision between calls while using the same prepared command handle.
  • Ensure that Parameters.Clear() is called before re-adding parameters with new definitions, or instantiate a new command object instead of reusing an old one with altered schemas.

Alternative or Verification Steps

  • Verification: Monitor the SQL Server Error Log (via SSMS > Management > SQL Server Logs) or Windows Event Viewer after implementing the fix; confirm that Error 8026 no longer appears during peak application load testing.
  • Alternative Fix: If the error persists specifically after a schema change, restart the SQL Server service (net stop MSSQLSERVER && net start MSSQLSERVER) to fully purge the plan cache and reset metadata handles across all active sessions.

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

Troubleshooting Guide: SQL Server Error 8024 – Invalid Collation for sql_variant TDS Parameter

Why This Error Happens

This error occurs when a client application sends an RPC call to SQL Server 2025 with a sql_variant parameter whose type-specific metadata contains a collation ID that does not exist in the server’s internal collation table. This typically happens due to a mismatched or outdated TDS driver (ODBC, OLE DB, or JDBC) that incorrectly encodes collation bytes, or because the client-side data access layer was built against a different SQL Server collation version than the one installed on Windows Server 2025. It can also result from corrupted driver binaries or a manually crafted/malformed RPC packet from a custom application.

Step-by-Step Resolution Guide

Step 1: Verify and Update the Client Driver

  • Check the data access driver version being used (ODBC Driver, OLE DB Provider, or JDBC Driver) in your application’s connection string.
  • On Windows 11/Server 2025, confirm installed driver version via Control Panel > ODBC Data Sources (64-bit) > Drivers tab.
  • Update to the latest Microsoft ODBC Driver 18+ or the current Microsoft JDBC Driver, as older drivers may misencode sql_variant collation metadata.

Step 2: Validate Server and Database Collation Consistency

  • Run SELECT SERVERPROPERTY('Collation'); to confirm the instance-level collation.
  • Compare this with the database collation using SELECT DATABASEPROPERTYEX('YourDBName', 'Collation');.
  • If collations differ unexpectedly after a migration or restore, align them using ALTER DATABASE YourDBName COLLATE <CorrectCollationName>;.

Step 3: Inspect the Application Code Generating the RPC Call

  • Review any code paths that explicitly set a parameter as SqlDbType.Variant (in .NET) or bind SQL_VARIANT in native client code.
  • Ensure the application is not manually constructing TDS packets or bypassing the driver’s parameter binding, which can corrupt collation bytes.
  • Where possible, cast the parameter to a strongly typed SQL type (e.g., nvarchar, int) instead of sql_variant to avoid passing raw collation metadata.

Step 4: Reinstall or Repair the Native Client Components

  • Use Programs and Features in Windows Server 2025 to repair or reinstall the SQL Server Native Client / ODBC Driver.
  • Run: msiexec /fa {ProductCode} if you have the driver’s MSI product code, or simply download a fresh installer from the official Microsoft SQL Server download page.
  • Restart the application pool or service consuming the connection after reinstalling.

Step 5: Capture and Analyze a Network Trace

  • Use SQL Server Profiler or Extended Events (sqlserver.rpc_starting and sqlserver.rpc_completed) to capture the exact RPC call triggering Error 8024.
  • Cross-reference the parameter index reported in the error (Parameter %d) with your application’s stored procedure call to pinpoint the exact faulty variable.

Alternative or Verification Steps

  • After applying driver updates or code changes, re-run the failing stored procedure call and confirm Error 8024 no longer appears in the SQL Server error log (SQL Server Logs in SSMS or xp_readerrorlog).
  • As an alternative, if the issue persists, avoid using sql_variant parameters entirely by refactoring the stored procedure to accept explicitly typed parameters, which eliminates the collation metadata dependency altogether.

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

Troubleshooting Guide: SQL Server Error 8023 – Invalid TDS RPC Parameter Data Type

Why This Error Happens

This error occurs when the TDS (Tabular Data Stream) protocol layer detects that a parameter sent by the client application does not match the data type expected by SQL Server 2025 for that RPC call. It is typically caused by a client driver mismatch (e.g., an outdated ODBC/OLE DB/ADO.NET provider), application code passing a malformed or oversized value (such as a string exceeding NVARCHAR length or an invalid DECIMAL precision), or corrupted parameter binding in a prepared statement cache. Since the error originates at the protocol level, SQL Server rejects the batch before execution, meaning the root cause almost always lies on the client side rather than within the database engine itself.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Parameter and Query

  • Capture the exact RPC call using SQL Server Profiler or Extended Events (rpc_completed and rpc_starting events) to see the full parameter list and values.
  • Note the parameter number (%d) and data type (%.*ls) mentioned in the error message—this tells you exactly which value is malformed.
  • Cross-reference the parameter against the stored procedure or parameterized query definition using sp_help '<procedure_name>'.

Step 2: Update Client Drivers and Connection Libraries

  • On Windows 11 or Windows Server 2025, open Settings > Apps > Installed Apps and check the version of “Microsoft OLE DB Driver for SQL Server” or “ODBC Driver for SQL Server.”
  • Download and install the latest driver from the Microsoft Download Center, ensuring compatibility with SQL Server 2025 (minimum ODBC 18.x or MSOLEDBSQL 19.x).
  • Restart the client application/service after driver installation to force re-registration of the TDS handshake version.

Step 3: Validate Application-Side Parameter Binding

  • Review application code (C#, Java, Python, etc.) for explicit parameter type declarations, ensuring types like SqlDbType.NVarChar or DECIMAL(p,s) match the target column definition exactly.
  • Check for truncation issues, such as passing a 5000-character string into an NVARCHAR(4000) field, or a floating-point value into an INT parameter.
  • If using an ORM (Entity Framework, Hibernate, etc.), clear the metadata cache and regenerate the model from the current database schema to eliminate stale type mappings.

Step 4: Clear the Procedure Cache on SQL Server

  • Connect via SQL Server Management Studio (SSMS) 21 or Azure Data Studio.
  • Run the following command to remove potentially corrupted cached execution plans tied to the stored procedure:
DBCC FREEPROCCACHE;
  • For a more targeted approach, use sp_recompile '<procedure_name>' to force recompilation of just the affected object without flushing the entire cache.

Step 5: Test with a Minimal Repro Script

  • Isolate the failing call into a standalone T-SQL script using hardcoded values that mimic the application’s input.
  • Execute the script directly in SSMS to confirm whether the error is reproducible outside the application layer, confirming whether the issue is client-side or server-side.

Alternative or Verification Steps

  • Verify the fix: Re-run the original application transaction and confirm Error 8023 no longer appears in the SQL Server Error Log (Management > SQL Server Logs in SSMS) or Windows Event Viewer under Applications and Services Logs > MSSQLSERVER.
  • Alternative solution: If the error persists intermittently, enable TDS 8.0 strict mode logging via SQL Server Configuration Manager > Protocols for MSSQLSERVER > Flags to capture deeper protocol-level diagnostics for malformed packets.

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

Why This Error Happens

Error 8021 occurs when a client application sends a Remote Procedure Call (RPC) containing a CLR-based parameter (such as a custom User-Defined Type like hierarchyid, geography, or a user-created CLR UDT) but the database context referenced in the TDS stream does not match the database where that CLR type/assembly is actually registered. Because CLR UDTs are scoped to a specific database, SQL Server 2025 rejects the call if the connection’s current database context shifts (e.g., via USE statements, connection pooling, or multi-database queries) without the destination database having the same type registered. This is frequently triggered by outdated or mismatched client drivers (ODBC, OLE DB, or SqlClient) that construct malformed RPC packets incompatible with the newer TDS protocol revisions in SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify the CLR Type Registration in the Target Database

  • Connect via SSMS and run SELECT * FROM sys.assemblies; against the database the application is actually targeting.
  • Confirm the CLR UDT (e.g., a custom type like dbo.GeoPoint) exists in that specific database, not just in model or a different database on the same instance.
  • If missing, re-deploy the CLR assembly using CREATE ASSEMBLY and CREATE TYPE scoped to the correct database.

Step 2: Check the Client Connection String and Database Context

  • Inspect the application’s connection string for the Database= or Initial Catalog= parameter and ensure it matches the database containing the CLR type.
  • If the application uses USE [OtherDB] mid-session or relies on connection pooling across multiple databases, isolate the CLR-type queries to a dedicated connection pinned to the correct database.
  • For .NET apps, verify SqlConnection.ChangeDatabase() calls aren’t silently switching context before the RPC call executes.

Step 3: Update Client Drivers and Provider Versions

  • Open Control Panel > Programs and Features on Windows Server 2025 / Windows 11 and check the version of “Microsoft OLE DB Driver for SQL Server” or “ODBC Driver for SQL Server.”
  • Download and install the latest driver matching SQL Server 2025’s TDS 8.0 protocol from the official Microsoft Download Center.
  • Restart the application pool (IIS) or the client service after driver installation to force reload of the updated sqlncli/msoledbsql libraries.

Step 4: Validate Server-Side CLR Integration Settings

  • Run sp_configure 'clr enabled'; on the instance to confirm CLR integration is turned on (value should be 1).
  • If recently migrated from an older SQL Server version, run ALTER DATABASE [YourDB] SET TRUSTWORTHY ON; only if the assembly requires EXTERNAL_ACCESS or UNSAFE permission sets, and re-validate assembly signing/certificates.
  • Check Event Viewer > Applications and Services Logs > SQL Server Logs for companion errors (e.g., Error 6522) indicating assembly load failures.

Alternative or Verification Steps

  • Reproduce the call using SQL Server Profiler or Extended Events (rpc_completed event) to inspect the raw RPC parameter list and confirm the database ID byte in the TDS stream now matches the target database.
  • If the error persists after driver updates, as a fallback, convert the CLR UDT parameter to a standard scalar type (e.g., pass VARBINARY(MAX) and reconstruct the UDT server-side) to bypass client-side TDS serialization issues entirely.

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

Troubleshooting Guide: SQL Server Error 8022 – TDS RPC Protocol Stream Error

Why This Error Happens

Error 8022 occurs when a client application sends a Remote Procedure Call (RPC) to SQL Server 2025 with a parameter explicitly set to NULL, while the target column or stored procedure parameter is defined with a NOT NULL constraint. This typically stems from a mismatch between the application’s data layer (such as an ORM, ETL tool, or custom ADO.NET/ODBC code) and the actual database schema. It can also occur after a schema migration where a column’s nullability was changed without updating the corresponding application logic or data mapping layer.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Parameter and Procedure

  • Capture the full error text; it includes the specific parameter number and name (e.g., Parameter 3 (“@CustomerEmail”)).
  • Use SQL Server Profiler or Extended Events (xp_trace or the rpc_completed event) to capture the exact RPC call payload being sent from the client.
  • Cross-reference the parameter name against the stored procedure definition using:
  sp_help 'YourStoredProcedureName';

Step 2: Verify Schema Constraints on the Target Table

  • Open SQL Server Management Studio (SSMS) and navigate to the table referenced in the procedure.
  • Run the following query to check nullability settings:
  SELECT COLUMN_NAME, IS_NULLABLE, DATA_TYPE 
  FROM INFORMATION_SCHEMA.COLUMNS 
  WHERE TABLE_NAME = 'YourTableName';
  • Confirm if a recent migration or ALTER TABLE script incorrectly added a NOT NULL constraint to a column that the application still treats as optional.

Step 3: Correct the Application Data Source

  • Check the ETL source (flat file, API response, or upstream database) for missing or blank values in the mapped field.
  • In SSIS packages, inspect the Data Flow Task for “Derive Column” transformations that might be failing to supply a default value.
  • If using C#/.NET, ensure the SqlParameter object is not defaulting to DBNull.Value when the business logic requires a specific input:
  command.Parameters.AddWithValue("@CustomerEmail", (object)email ?? "default@domain.com");

Step 4: Implement a Database-Level Default Constraint (If Applicable)

  • If NULL values are a valid business scenario but the schema is too strict, consider altering the table to accept NULLs if business logic allows.
  • Alternatively, add a DEFAULT constraint to handle missing data gracefully at the database level:
  ALTER TABLE YourTableName 
  ADD CONSTRAINT DF_CustomerEmail DEFAULT 'N/A' FOR CustomerEmail;

Alternative or Verification Steps

  • Verification: Re-run the specific client transaction or ETL job that triggered the error and monitor the SQL Server Error Log (Event Viewer > Applications and Services Logs > MSSQLSERVER) to confirm Error 8022 no longer appears.
  • Alternative: If the issue persists intermittently, implement a TRY-CATCH block within the stored procedure to log the specific incoming parameter values to a debug table before the NULL check fails, allowing you to trace the exact upstream source of the bad data.

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

Troubleshooting Guide: SQL Server Error 8020 (TDS/RPC CLR Serialization Metadata Error)

Why This Error Happens

This error occurs when a client application sends an RPC call to SQL Server 2025 with a CLR-based parameter (such as a UDT, geometry, geography, or custom CLR type) whose serialized length metadata does not match what SQL Server expects based on the type’s registered assembly definition. This mismatch is commonly caused by an outdated or mismatched client driver (ODBC, OLE DB, or SqlClient) that doesn’t align with the CLR type version deployed on the server, or by a corrupted/incompatible CLR assembly registered in the database. It can also surface after an in-place upgrade to SQL Server 2025 where legacy CLR assemblies were not recompiled against the updated .NET runtime hosted inside SQL Server.

Step-by-Step Resolution Guide

Step 1: Verify and Update Client Drivers

  • Confirm the application is using the latest Microsoft OLE DB Driver (MSOLEDBSQL19+) or Microsoft.Data.SqlClient (v5.x or later) compatible with SQL Server 2025.
  • On Windows 11/Windows Server 2025, check installed driver versions via Control Panel > Programs and Features or run:
  Get-OdbcDriver | Where-Object {$_.Name -like "*SQL Server*"}
  • Uninstall outdated legacy drivers (e.g., SQL Server Native Client 11.0) and reinstall the current Microsoft OLE DB Driver for SQL Server.

Step 2: Re-register and Validate CLR Assemblies

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run the following to identify the problematic assembly tied to the parameter type referenced in the error:
  SELECT * FROM sys.assemblies;
  SELECT * FROM sys.assembly_types;
  • Drop and re-add the CLR assembly using ALTER ASSEMBLY with the WITH PERMISSION_SET clause matching your security requirements:
  ALTER ASSEMBLY YourAssemblyName
  FROM 'C:\Path\To\YourAssembly.dll'
  WITH PERMISSION_SET = SAFE;
  • Ensure the assembly was compiled against the correct .NET target version supported by SQL Server 2025 (.NET 8+ CLR integration).

Step 3: Check TDS Protocol Version Alignment

  • Verify the SQL Server instance is running the latest Cumulative Update (CU) for SQL Server 2025 via:
  SELECT @@VERSION;
  • Confirm Windows Server 2025 / Windows 11 has the latest .NET Framework and .NET runtime updates installed via Windows Update, as TDS/CLR serialization depends on matching runtime libraries.
  • Restart the SQL Server service after updates:
  Restart-Service -Name MSSQLSERVER -Force

Step 4: Rebuild the Parameter Metadata Cache

  • Clear the procedure cache to eliminate stale execution plans referencing outdated CLR parameter metadata:
  DBCC FREEPROCCACHE;
  • Re-execute the failing stored procedure or RPC call to confirm the parameter metadata rebuilds correctly.

Alternative or Verification Steps

  • Run a test RPC call using sqlcmd -S servername -d dbname -Q "EXEC YourProcedure" to confirm the error no longer appears in isolation from the application layer.
  • If the issue persists, capture a network trace using SQL Server Profiler or Extended Events (rpc_completed event) to inspect the raw parameter payload and confirm the CLR type length byte matches the assembly’s current schema.

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

Why This Error Happens

Error 8018 occurs when a client application or stored procedure attempts to pass deprecated large object (LOB) data types—such as TEXT, NTEXT, or IMAGE—as parameters to SQL Server 2025, which has tightened enforcement around these legacy types in favor of VARCHAR(MAX), NVARCHAR(MAX), and VARBINARY(MAX). This typically surfaces after an upgrade from an older SQL Server version or Windows Server migration, where connection strings, ORM mappings (Entity Framework, ADO.NET), or legacy stored procedures still reference the old schema definitions. It can also happen if a third-party driver or application has not been updated to align with the newer Tabular Data Stream (TDS) protocol restrictions enforced in SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Column or Parameter

  • Run sp_help 'YourTableName' in SQL Server Management Studio (SSMS) to inspect column data types.
  • Look specifically for text, ntext, or image types in the output.
  • Cross-reference the parameter number reported in the error message (%d) with your stored procedure or query parameter order.

Step 2: Alter the Table Schema to Use Modern Data Types

  • Open a new query window in SSMS connected to the affected database.
  • Run a schema update script, for example:
  ALTER TABLE dbo.YourTableName
  ALTER COLUMN YourColumnName VARCHAR(MAX);
  • For NTEXT, convert to NVARCHAR(MAX); for IMAGE, convert to VARBINARY(MAX).
  • Rebuild any dependent indexes using ALTER INDEX ALL ON dbo.YourTableName REBUILD;.

Step 3: Update Stored Procedures and Application Code

  • Search all stored procedures using:
  SELECT OBJECT_NAME(object_id), definition
  FROM sys.sql_modules
  WHERE definition LIKE '%TEXT%' OR definition LIKE '%IMAGE%';
  • Update any CREATE PROCEDURE or CREATE FUNCTION definitions to reference the new MAX-based types.
  • If using Entity Framework or Dapper, update the model mappings in your .edmx or DbContext configuration to reflect string or byte[] mapped to MAX types.

Step 4: Update Client Drivers and Connection Configuration

  • Ensure the Windows Server 2025 / Windows 11 machine has the latest Microsoft ODBC Driver 18+ or OLE DB Driver installed via Microsoft Update or the official installer.
  • Verify the connection string does not force legacy TDS versions (remove any TDS_Version=7.0 type flags).
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER in PowerShell (run as Administrator) after driver updates.

Step 5: Validate Compatibility Level Settings

  • Check the database compatibility level with:
  SELECT name, compatibility_level FROM sys.databases;
  • If set below 160, update it using:
  ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 170;
  • This ensures the database engine fully enforces and recognizes the newer MAX data type behaviors.

Alternative or Verification Steps

  • Re-run the original query or application transaction that triggered Error 8018 and confirm no exception is thrown in the SQL Server Error Log (Application Event Viewer or ERRORLOG file in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\).
  • If the error persists, use SQL Server Profiler or Extended Events to trace the exact RPC call and parameter payload, confirming whether a third-party application (not your schema) is still sending deprecated LOB types.

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

Troubleshooting Guide: SQL Server Error 8019 — Invalid User Type for CLR Parameter

Why This Error Happens

Error 8019 occurs when a client application sends an RPC call to SQL Server 2025 with a parameter marked as a CLR (Common Language Runtime) data type, but the associated user-defined type (UDT) is either not registered, mismatched, or has an invalid schema reference on the server side. This typically happens after a CLR assembly is updated, dropped, or deployed inconsistently between client and server, causing the TDS stream to reference a UDT ID that SQL Server cannot resolve. It can also occur when the client-side driver (e.g., SqlClient) and the server have mismatched metadata caches for a user-defined type such as geography, geometry, hierarchyid, or a custom CLR UDT.

Step-by-Step Resolution Guide

Step 1: Verify the CLR Assembly and User-Defined Type Registration

  • Connect to the instance via SQL Server Management Studio (SSMS) and run:
  • SELECT * FROM sys.assemblies;
  • SELECT * FROM sys.assembly_types;
  • Confirm the UDT referenced by the failing parameter actually exists and is correctly bound to its assembly.
  • If the assembly was recently redeployed, check for version mismatches using SELECT assembly_id, name, clr_name FROM sys.assembly_types;

Step 2: Rebuild and Redeploy the CLR Assembly

  • Drop and recreate the affected UDT and assembly to clear any corrupted metadata:
  • DROP TYPE IF EXISTS dbo.YourUDTName;
  • DROP ASSEMBLY IF EXISTS YourAssemblyName;
  • Redeploy using CREATE ASSEMBLY ... FROM 'C:\Path\To\Assembly.dll' WITH PERMISSION_SET = SAFE;
  • Recreate the type: CREATE TYPE dbo.YourUDTName EXTERNAL NAME YourAssemblyName.[ClassName];

Step 3: Clear Client-Side Metadata Cache

  • On the application server (Windows Server 2025 / Windows 11), restart the application pool or client service to flush any cached SqlClient type metadata.
  • If using connection pooling, clear the pool explicitly:
  • SqlConnection.ClearAllPools(); (in .NET code) or restart IIS via iisreset.
  • Ensure the client-side driver version (Microsoft.Data.SqlClient) matches the SQL Server 2025 compatibility requirements.

Step 4: Check SQL Server Compatibility Level and Patch Status

  • Run SELECT compatibility_level FROM sys.databases WHERE name = 'YourDatabase'; to confirm it aligns with SQL Server 2025 standards.
  • Apply the latest Cumulative Update (CU) for SQL Server 2025, as CLR/UDT metadata bugs are frequently patched.
  • Verify via SELECT @@VERSION; after patching.

Step 5: Re-test the RPC Call

  • Re-run the original query or stored procedure call that triggered Error 8019 from both SSMS and the application layer.
  • Monitor SQL Server Error Logs (Management > SQL Server Logs in SSMS) for recurrence of Error 8019.

Alternative or Verification Steps

  • Use SQL Server Profiler or Extended Events to capture the exact RPC call and confirm the parameter’s data type ID now matches a valid registered UDT.
  • If the issue persists, bypass the CLR UDT entirely by converting the parameter to a standard SQL data type (e.g., VARBINARY(MAX)) as a temporary workaround while investigating deeper assembly versioning conflicts.

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

Troubleshooting Guide: SQL Server Error 8017 (Invalid Precision or Scale in TDS RPC Stream)

Why This Error Happens

This error occurs when a client application sends a Remote Procedure Call (RPC) to SQL Server 2025 with a parameter whose data type requires precision and scale values (such as DECIMAL, NUMERIC, or DATETIME2), but those values are either missing, malformed, or exceed the allowed range (precision 1–38). This is typically caused by a mismatch between the client driver version (ODBC, OLE DB, or ADO.NET) and the SQL Server TDS protocol version, or by a bug in custom application code that manually constructs TDS parameter metadata. Corrupted or outdated client-side driver files on Windows 11 or Windows Server 2025 can also send malformed packets that the Database Engine rejects before execution.

Step-by-Step Resolution Guide

Step 1: Update and Verify the Client Driver

  • Confirm the application is using a TDS-compliant driver that supports SQL Server 2025 (ODBC Driver 18+ or Microsoft.Data.SqlClient 5.x+).
  • On Windows 11/Server 2025, check installed driver version via Control Panel > ODBC Data Sources (64-bit) > Drivers tab.
  • Reinstall or update using: winget install Microsoft.ODBCDriverforSQLServer

Step 2: Inspect the Parameter Definitions in Application Code

  • Review any stored procedure calls that pass DECIMAL(p,s) or NUMERIC(p,s) parameters and confirm precision does not exceed 38 and scale does not exceed precision.
  • Check for hardcoded or dynamically generated TDS parameter metadata in custom data-access layers (common in legacy .NET or Java JDBC apps).
  • Example fix in C#: explicitly set SqlParameter.Precision and SqlParameter.Scale before execution rather than relying on type inference.

Step 3: Capture and Analyze the TDS Stream

  • Use SQL Server Profiler or Extended Events (sp_server_diagnostics) to capture the exact RPC call triggering Error 8017.
  • Filter on Event ID 8017 and inspect the %d parameter index and %.*ls parameter name reported in the error text to isolate the offending column.
  • Cross-reference the parameter against the target table/stored procedure schema using:
  SELECT name, system_type_name, precision, scale 
  FROM sys.dm_exec_describe_first_result_set_for_object(OBJECT_ID('YourProcName'), 0);

Step 4: Repair or Reset the SQL Server Client Configuration

  • On the Windows machine running the client app, clear any cached connection strings or UDL files that may reference an outdated provider.
  • Run sfc /scannow on Windows Server 2025/Windows 11 to rule out corrupted system DLLs affecting the OLE DB/ODBC stack.
  • Restart the SQL Server (MSSQLSERVER) service after driver updates via services.msc or Restart-Service MSSQLSERVER.

Alternative or Verification Steps

  • Re-run the failing query/application action and confirm Error 8017 no longer appears in the SQL Server Error Log (Management > SQL Server Logs in SSMS).
  • If the issue persists, isolate the problem by testing the same RPC call directly in SSMS using EXEC with explicitly cast parameters to confirm whether the fault lies in SQL Server or the client application layer.

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

Troubleshooting Guide: SQL Server Error 8016 – Invalid TDS RPC Data Length

Why This Error Happens

Error 8016 occurs when the SQL Server Tabular Data Stream (TDS) parser receives a Remote Procedure Call (RPC) request where a parameter’s declared metadata length does not match the actual data length sent by the client. This typically stems from a mismatched or outdated client driver (ODBC, OLE DB, or ADO.NET) that incorrectly serializes parameter data types—especially with large object types like VARCHAR(MAX), VARBINARY(MAX), or XML. It can also be triggered by application-level bugs where a parameter is bound with an incorrect size or a NULL-length mismatch, or by network packet corruption/truncation affecting the TDS stream mid-transmission.

Step-by-Step Resolution Guide

Step 1: Update and Verify Client Drivers

  • Confirm the application is using the latest Microsoft ODBC Driver 18+ or OLE DB Driver for SQL Server, compatible with SQL Server 2025’s TDS 8.0 protocol revisions.
  • Check driver version via Control Panel > ODBC Data Sources (64-bit) > Drivers tab.
  • Download updates from the official Microsoft Learn SQL connectivity page if the driver predates late-2024 builds.

Step 2: Audit Application Parameter Binding

  • Review the application code (ADO.NET, JDBC, or ODBC calls) for any SqlParameter or SQLBindParameter definitions where Size is set to 0, negative, or omitted for MAX-type columns.
  • Explicitly set Parameter.Size = -1 for VARCHAR(MAX)/NVARCHAR(MAX)/VARBINARY(MAX) in .NET to force correct TDS length encoding.
  • Enable SQL Server Profiler or Extended Events (rpc_completed) to capture the exact failing RPC call and inspect the parameter payload.

Step 3: Validate Network Packet Integrity

  • Open SQL Server Configuration Manager and navigate to SQL Server Network Configuration > Protocols for MSSQLSERVER.
  • Check the TCP/IP properties and ensure Packet Size in the client connection string matches server expectations (default 4096 bytes; avoid manual overrides unless necessary).
  • Run netsh int tcp show global on Windows Server 2025 to confirm TCP Chimney Offload and RSS settings aren’t corrupting packet boundaries.

Step 4: Apply Latest SQL Server 2025 Cumulative Update

  • Open SQL Server Management Studio (SSMS) and run SELECT @@VERSION; to check your current build.
  • Compare against the latest Cumulative Update (CU) listed on the Microsoft SQL Server release notes page.
  • Install the newest CU via Windows Update or the standalone .exe patch, then restart the MSSQLSERVER service.

Step 5: Rebuild Affected Stored Procedures

  • If the error correlates with a specific stored procedure, drop and recreate it using sp_recompile 'SchemaName.ProcName'; to clear any cached, corrupted execution plan metadata.
  • Verify parameter data types in the procedure definition exactly match the types passed by the application.

Alternative or Verification Steps

  • Re-run the failing transaction after driver/CU updates while monitoring Extended Events (rpc_completed, error_reported) to confirm Error 8016 no longer appears in the trace.
  • If the issue persists, isolate the problem by testing the same RPC call directly in SSMS using EXEC with identical parameter values—if it succeeds in SSMS but fails from the application, the root cause is confirmed to be client-side parameter serialization.

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

Troubleshooting Guide: SQL Server Error 8014 — Invalid sql_variant Type-Specific Metadata

Why This Error Happens

This error occurs when the TDS (Tabular Data Stream) protocol stream sent from a client application to SQL Server 2025 contains a malformed sql_variant parameter, specifically where the internal type-specific metadata (such as precision, scale, or collation bytes) does not match what the base data type requires. This is typically caused by an outdated or buggy client driver (ODBC, OLE DB, or ADO.NET) that incorrectly serializes the sql_variant payload, or by a custom application manually constructing RPC calls with corrupted parameter definitions. It can also surface after a driver mismatch following an OS upgrade to Windows Server 2025 or Windows 11, where legacy native client libraries are no longer fully compatible with the newer TDS protocol revisions.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Client and Driver Version

  • Check the SQL Server error log and Windows Event Viewer (Application log) for the exact timestamp and source application name tied to Error 8014.
  • Run SELECT * FROM sys.dm_exec_connections WHERE session_id = <id> to identify the client_net_address and protocol_version of the connection that triggered the error.
  • Confirm which driver the application uses (SQL Server Native Client, Microsoft ODBC Driver 17/18, or System.Data.SqlClient/Microsoft.Data.SqlClient).

Step 2: Update the Client Driver and .NET/ODBC Components

  • Download and install the latest Microsoft ODBC Driver (18.x or later) from the official Microsoft Download Center.
  • If using .NET applications, update the NuGet package to the latest Microsoft.Data.SqlClient version, as older System.Data.SqlClient builds have known sql_variant serialization bugs.
  • Restart the application pool or service (iisreset for IIS-hosted apps, or restart the Windows Service) after the driver update to ensure the new binaries are loaded.

Step 3: Audit the Application Code Sending the sql_variant Parameter

  • Search the application source (or stored procedure call) for any parameter explicitly typed as SqlDbType.Variant or sql_variant.
  • Ensure the underlying .NET object assigned to that parameter is a supported base type (e.g., int, nvarchar, datetime2 is NOT valid inside sql_variant — use datetime instead).
  • Avoid passing DBNull.Value directly without explicitly casting it to a compatible SqlDbType, as ambiguous null typing can corrupt the metadata header.

Step 4: Apply the Latest SQL Server 2025 Cumulative Update

  • Open SQL Server Configuration Manager and verify the current build number via SELECT @@VERSION.
  • Navigate to the Microsoft Update Catalog and apply the latest Cumulative Update (CU) for SQL Server 2025, as this error has specific TDS-parsing fixes documented in recent CU release notes.
  • Reboot the instance via Services.msc (restart the “SQL Server (MSSQLSERVER)” service) after patching.

Step 5: Capture a Network Trace to Isolate Malformed Packets (If Error Persists)

  • Use SQL Server Profiler or Extended Events with the rpc_completed and user_error_message events to capture the exact failing RPC call.
  • Cross-reference the captured parameter payload against the TDS specification for sql_variant (Type, MaxLen, and type-specific metadata bytes) to confirm the malformed field.

Alternative or Verification Steps

  • After applying driver updates, re-run the failing query/application action and confirm Error 8014 no longer appears in sys.dm_os_ring_buffers or the SQL Server error log.
  • If the error persists after driver and CU updates, temporarily change the parameter type from sql_variant to a fixed, explicit data type (e.g., nvarchar(max)) in both the stored procedure and application code as a workaround while escalating the driver bug to Microsoft Support.

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

Troubleshooting Guide: SQL Server Error 8015 – Untyped NULL Marked as Output Parameter

Why This Error Happens

Error 8015 occurs when a client application sends a Remote Procedure Call (RPC) to SQL Server with a parameter that is declared as an output parameter but is passed as a generic NULL value without an explicit data type. SQL Server’s TDS protocol parser requires every output parameter to carry explicit type metadata (such as varchar, int, or datetime) so it knows what format to use when returning data back to the caller. This typically stems from a bug in client-side driver code, an ORM (like Entity Framework or ADO.NET) misconfiguration, or a manually crafted RPC call that fails to bind a proper SqlDbType to the parameter object before execution.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Stored Procedure Call

  • Enable SQL Server Profiler or Extended Events to capture the exact RPC:Starting event that triggers Error 8015.
  • Note the parameter name/index (%d) and procedure name reported in the error message.
  • Cross-reference this with your application logs to locate the source code block issuing the call.

Step 2: Correct the Parameter Type Binding in Application Code

  • In ADO.NET/C#, ensure every output parameter explicitly sets SqlDbType and Size before setting Direction = ParameterDirection.Output.
  • Example fix:
  SqlParameter outputParam = new SqlParameter("@ResultValue", SqlDbType.Int);
  outputParam.Direction = ParameterDirection.Output;
  command.Parameters.Add(outputParam);
  • Avoid assigning DBNull.Value or null directly to an output parameter without first defining its SqlDbType.

Step 3: Update or Patch the Database Driver

  • Verify you are using the latest Microsoft ODBC Driver or OLE DB Driver compatible with SQL Server 2025.
  • Navigate to C:\Program Files\Microsoft SQL Server\Client SDK\ and confirm driver version numbers match Microsoft’s current release notes.
  • If using a third-party ORM (e.g., Hibernate, Sequelize), check for a patched release that resolves known TDS parameter-binding issues with SQL Server 2025.

Step 4: Validate Stored Procedure Definitions

  • Open SQL Server Management Studio (SSMS) and run sp_helptext 'YourProcedureName' to confirm the output parameter data types defined in T-SQL match what the client expects.
  • Ensure there is no mismatch between the procedure’s declared parameter type (e.g., @Status INT OUTPUT) and what the client is attempting to pass.

Step 5: Restart the SQL Server Service and Re-test

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Restart the SQL Server (MSSQLSERVER) service to clear any cached execution plans related to the faulty RPC call.
  • Re-run the application transaction that previously triggered Error 8015.

Alternative or Verification Steps

  • Use SQL Server Profiler to re-capture the RPC call after the fix; confirm the parameter now shows a defined SqlDbType instead of an untyped NULL in the TDS stream.
  • If the error persists, bypass the ORM temporarily and execute the stored procedure manually via SSMS with explicitly typed parameters to confirm the procedure itself is not the root cause.

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

Troubleshooting Guide: SQL Server Error 8012 (TDS RPC Protocol Stream Error)

Why This Error Happens

This error occurs when a client application sends an RPC call to SQL Server 2025 with a sql_variant parameter whose type-specific metadata (precision/scale bytes) is malformed or incorrectly encoded by the client’s TDS library. It typically stems from an outdated or buggy ODBC/OLE DB driver, a custom application incorrectly constructing TDS packets, or a mismatch between the client driver version and the SQL Server 2025 TDS protocol revision. Occasionally, this is also triggered by corrupted connection pooling state that reuses a malformed parameter definition across requests.

Step-by-Step Resolution Guide

Step 1: Update the Client Driver and Connectivity Components

  • Check the driver version used by the failing application (ODBC Driver, OLE DB Provider (MSOLEDBSQL), or SqlClient/Microsoft.Data.SqlClient).
  • Download and install the latest driver compatible with SQL Server 2025 from the official Microsoft Download Center.
  • On Windows 11/Windows Server 2025, verify installed versions via Control Panel > Programs and Features or run:
  Get-OdbcDriver | Where-Object {$_.Name -like "*SQL Server*"}
  • Restart the application pool or service after updating.

Step 2: Inspect and Correct the Application’s Parameter Binding

  • Review the code path that defines the sql_variant parameter (often via SqlParameter or SQLBindParameter).
  • Ensure the parameter does not explicitly set an invalid precision/scale combination (e.g., scale greater than precision, or negative values).
  • If using SqlDbType.Variant in .NET, avoid manually setting Precision or Scale properties—let the driver infer them automatically.
  • For ODBC-based apps, confirm SQL_C_BINARY or appropriate C type mapping is used instead of a mismatched numeric type for variant columns.

Step 3: Capture and Analyze the TDS Stream

  • Use SQL Server Profiler or Extended Events (rpc_completed, rpc_starting) to capture the exact RPC call causing the error.
  • Alternatively, capture a network trace with Wireshark using the tds protocol filter to inspect the raw parameter metadata bytes.
  • Identify the specific parameter index referenced in the error message (Parameter %d) and cross-reference it with the application’s stored procedure call.

Step 4: Validate SQL Server Configuration and Compatibility Level

  • Confirm the database compatibility level supports sql_variant operations as expected:
  SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabase';
  • If recently migrated from an older SQL Server version, run:
  DBCC CHECKDB WITH DATA_PURITY;
  • Ensure no legacy linked server or middleware (e.g., older MSDTC or connection pooler) is reformatting RPC calls incorrectly.

Step 5: Rebuild the Affected Stored Procedure or Query

  • If the error originates from a stored procedure using sql_variant input/output parameters, drop and recreate the procedure to refresh its metadata cache.
  • Clear the procedure cache if stale plans are suspected:
  DBCC FREEPROCCACHE;

Alternative or Verification Steps

  • Re-run the failing operation from a clean client session (new connection, no pooling) to confirm the malformed metadata was tied to a cached connection state rather than a persistent server-side issue.
  • If the issue persists only with a specific driver, test the same RPC call using sqlcmd or SSMS directly—if it succeeds there, the root cause is confirmed to be client-side driver/application logic rather than SQL Server 2025 itself.

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

Troubleshooting Guide: SQL Server Error 8013 – Invalid sql_variant Instance Length

Why This Error Happens

This error occurs when the TDS (Tabular Data Stream) protocol receives an RPC call containing a sql_variant parameter whose declared instance length does not match the actual data being transmitted, indicating a malformed or corrupted client request. This is typically caused by outdated or buggy client drivers (ODBC, OLE DB, or ADO.NET) that incorrectly serialize sql_variant data, a mismatch between the client library version and SQL Server 2025’s TDS protocol version, or packet corruption occurring over the network layer. In some cases, custom application code manually constructing RPC calls or using low-level TDS libraries may also generate improperly formatted parameter streams.

Step-by-Step Resolution Guide

Step 1: Update Client Drivers and Connectivity Components

  • Verify the version of the client driver (ODBC Driver, OLE DB Provider, or SqlClient) being used by the application.
  • On Windows Server 2025 / Windows 11, navigate to Settings > Apps > Installed Apps and check for “Microsoft ODBC Driver for SQL Server” or “Microsoft OLE DB Driver for SQL Server.”
  • Download and install the latest driver from the official Microsoft Download Center to ensure full compatibility with SQL Server 2025’s TDS 8.0 protocol.
  • Restart the application after updating to force it to load the new driver binaries.

Step 2: Capture and Inspect the TDS Stream

  • Use SQL Server Profiler or Extended Events to capture the RPC:Starting and RPC:Completed events around the time of the failure.
  • Filter the trace by the sql_variant parameter mentioned in the error message (the %.*ls placeholder will show the actual parameter name).
  • Export the trace and look specifically at the byte length prefix versus the actual payload size for the flagged parameter.
  • Cross-reference this with Wireshark (using the tds filter) if you need raw packet-level inspection of the malformed instance length.

Step 3: Validate Application Code for Manual RPC Construction

  • Search the application codebase for any manual TDS packet construction or low-level use of SqlDbType.Variant in .NET.
  • Ensure that any SqlParameter objects of type sql_variant are populated using properly typed .NET objects (e.g., int, decimal, DateTime) rather than raw byte arrays.
  • Replace any manual byte-length calculations with the driver’s built-in serialization methods to avoid off-by-one or endianness errors.

Step 4: Check Network Packet Integrity

  • Open SQL Server Configuration Manager, navigate to SQL Server Network Configuration > Protocols, and confirm that TCP/IP settings are not fragmenting packets unexpectedly.
  • Verify the Network Interface Card (NIC) driver on Windows Server 2025 is up to date, as outdated NIC drivers can cause silent packet corruption.
  • If using a load balancer or proxy between the client and SQL Server, verify it is not altering TDS packet payloads.

Step 5: Apply the Latest SQL Server Cumulative Update

  • Check SQL Server Management Studio (SSMS) > Help > About for the current build number.
  • Download the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Update Catalog, as this specific parsing bug may be patched in a servicing release.
  • Apply the update during a maintenance window and restart the SQL Server service.

Alternative or Verification Steps

  • To verify the fix, re-run the failing query or stored procedure call from the client application and confirm that Error 8013 no longer appears in the SQL Server Error Log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • If the error persists after driver and CU updates, temporarily bypass sql_variant parameters by explicitly casting them to a fixed data type (e.g., NVARCHAR(MAX)) in the stored procedure signature as a workaround while the root client-side issue is investigated further.

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

Troubleshooting Guide: SQL Server Error 8010 – TDS RPC Protocol Stream Metadata Mismatch

Why This Error Happens

This error occurs when the TDS (Tabular Data Stream) protocol receives an RPC (Remote Procedure Call) request where a parameter is flagged with the “metadata unchanged” bit, but SQL Server cannot locate previously cached metadata matching that parameter’s definition. This typically happens due to connection pooling issues, a mismatched or outdated client driver (such as an older ODBC or OLE DB provider communicating with SQL Server 2025), or an application incorrectly reusing a prepared statement handle across sessions with altered schema. Corrupted client-side statement caching or improper statement re-preparation after a schema change can also trigger this inconsistency.

Step-by-Step Resolution Guide

Step 1: Update Client Drivers and Connectivity Components

  • Ensure you are using the latest Microsoft ODBC Driver (18 or higher) or OLE DB Driver (MSOLEDBSQL19+) compatible with SQL Server 2025.
  • On Windows Server 2025 / Windows 11, download updates via Microsoft Update Catalog or the official SQL Server Feature Pack.
  • Restart the application pool or client service after installation to force reload of the new driver binaries.

Step 2: Clear and Reset Connection Pooling

  • Disable connection pooling temporarily in your application’s connection string (Pooling=false) to test if stale pooled connections are causing cached metadata conflicts.
  • If using .NET, call SqlConnection.ClearAllPools() programmatically to flush all cached connections.
  • Restart the IIS or application service to ensure no lingering TDS sessions remain active.

Step 3: Verify and Repair Prepared Statement Handling

  • Check application code for improper reuse of sp_prepare / sp_execute handles after DDL changes (e.g., ALTER TABLE, ALTER PROC).
  • Force statements to fully re-prepare by calling sp_unprepare before re-executing against a modified schema.
  • If using an ORM (Entity Framework, Dapper), clear any internal query/metadata cache explicitly after schema migrations.

Step 4: Capture and Analyze a Network Trace

  • Use SQL Server Profiler or Extended Events to capture the RPC:Starting and RPC:Completed events.
  • Cross-reference the failing parameter number (%d) from the error message against the actual stored procedure definition to identify the schema drift.
  • Run the following query to validate current parameter metadata:
sp_help 'YourStoredProcedureName';

Step 5: Restart SQL Server Services and Validate TDS Endpoint

  • Open SQL Server Configuration Manager and restart the SQL Server (MSSQLSERVER) service.
  • Confirm the TDS endpoint is healthy by checking:
SELECT * FROM sys.tcp_endpoints;
  • Ensure no third-party proxy or load balancer (e.g., HAProxy, pgbouncer-style TDS proxies) is altering RPC packets mid-stream.

Alternative or Verification Steps

  • Re-run the failing query/application transaction immediately after driver updates and pooling reset — if Error 8010 no longer appears in the SQL Server Error Log or Event Viewer (Event ID 8010), the fix is confirmed.
  • As an alternative, if the issue persists only under high concurrency, enable TRACEFLAG 7745 (query execution plan metadata trace) temporarily to log deeper RPC parameter mismatches for Microsoft Support escalation.

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

Troubleshooting Guide: SQL Server Error 8011 – Invalid sql_variant Metadata Length in TDS/RPC Stream

Why This Error Happens

This error occurs when the SQL Server Native Client, ODBC Driver, or a custom application incorrectly constructs the Tabular Data Stream (TDS) packet when passing a parameter typed as sql_variant through a Remote Procedure Call (RPC). Typically, this stems from a mismatched or outdated client-side driver that miscalculates the type-specific metadata length for the sql_variant header, or from a middle-tier application manually crafting TDS packets with corrupted byte offsets. In rarer cases, this can be triggered by network packet fragmentation or MTU mismatches corrupting the data mid-transit between the client and the Windows Server 2025 host.

Step-by-Step Resolution Guide

Step 1: Update and Verify the Client Driver Stack

  • Navigate to the application server and check installed driver versions via Control Panel > Programs and Features.
  • Ensure you are running the latest Microsoft OLE DB Driver for SQL Server or ODBC Driver 18+, as older drivers (pre-2022) have known sql_variant serialization bugs.
  • Download the latest driver from the official Microsoft Download Center if the version predates the SQL Server 2025 release cycle.

Step 2: Audit the Application Code for Parameter Binding

  • Review the application layer (e.g., .NET, Java JDBC, or PHP) where the RPC call is constructed.
  • Check that sql_variant parameters are explicitly cast with a defined length and base type before being sent (e.g., ensure a VARCHAR cast isn’t exceeding 8000 bytes before conversion to sql_variant).
  • If using SqlCommand in C#, verify the SqlDbType.Variant is correctly instantiated with a non-null, non-zero-length value.

Step 3: Capture and Analyze the Network Trace

  • Use Wireshark or SQL Server Profiler on the Windows Server 2025 instance to capture the raw TDS packet during the failed transaction.
  • Filter for the specific RPC call (sp_execute or sp_prepare) and inspect the hex dump for the sql_variant header.
  • Look for truncated byte sequences in the metadata length byte immediately following the TYPE_INFO token (0x62).

Step 4: Reset the TDS Endpoint and Restart Services

  • Open SQL Server Configuration Manager.
  • Navigate to SQL Server Network Configuration > Protocols for MSSQLSERVER.
  • Disable and re-enable the TCP/IP protocol to force a reset of the socket buffer, then restart the MSSQLSERVER service via PowerShell:
  Restart-Service -Name 'MSSQLSERVER' -Force

Alternative or Verification Steps

  • Verification: Run the specific stored procedure call manually via sqlcmd from the command line using the -C flag to trust the server certificate; if it executes successfully outside the application, the issue is confirmed to be in the application’s driver layer, not the SQL instance itself.
  • Alternative: If the error persists only on specific endpoints, bypass sql_variant entirely in the schema and refactor the column/parameter to a strongly-typed alternative (e.g., NVARCHAR(MAX)) to eliminate the ambiguous type-metadata parsing issue entirely.

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

Troubleshooting Guide: TDS RPC Protocol Stream Error 8007

Why This Error Happens

This error occurs when the TDS (Tabular Data Stream) protocol receives a malformed chunking sequence for a large object (LOB) parameter, such as VARCHAR(MAX), NVARCHAR(MAX), or VARBINARY(MAX). This is typically caused by a client-side driver bug or mismatch, an outdated or corrupted ODBC/OLE DB provider, or custom application code that manually constructs RPC parameter streams incorrectly. It can also surface when network packet fragmentation corrupts the data stream between the client and Microsoft SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Update the Client Driver and Connection Libraries

  • Verify which driver the application uses (ODBC Driver 18, OLE DB Driver, or .NET SqlClient) by checking the application’s connection string or dependency manifest.
  • Download and install the latest Microsoft ODBC Driver or Microsoft.Data.SqlClient NuGet package, as older drivers have known TDS chunking bugs with MAX-length parameters.
  • On Windows Server 2025, confirm the driver version via Control Panel > ODBC Data Sources (64-bit) > Drivers tab.

Step 2: Inspect and Correct Application-Level Parameter Binding

  • Review the application code for any manual TDS stream construction or custom bulk-copy implementations feeding large object parameters.
  • Ensure parameters are bound using proper SqlParameter types (e.g., SqlDbType.VarChar with explicit -1 size for MAX types) instead of hardcoded chunk lengths.
  • If using a third-party driver (JDBC, PHP, Node.js), confirm it correctly implements the PLP (Partially Length-Prefixed) format required for MAX data types in TDS 7.3+.

Step 3: Capture and Analyze the Network Trace

  • Use SQL Server Profiler or Extended Events to capture the RPC:Starting and RPC:Completed events around the failure.
  • Run a network capture with Wireshark (with TDS protocol dissector enabled) on port 1433 to inspect the actual byte stream for malformed PLP chunk terminators (0xFFFFFFFF end marker missing or corrupted).
  • Correlate the captured timestamp with the SQL Server error log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.

Step 4: Check for Network/Firewall Packet Fragmentation Issues

  • Validate that packet size settings match between client and server by checking Network Packet Size configuration in SQL Server Configuration Manager.
  • On Windows Server 2025, inspect firewall rules under Windows Defender Firewall with Advanced Security to ensure no MTU-related truncation occurs on port 1433.
  • Temporarily disable TCP Chimney Offload or large send offload (LSO) on the network adapter if packet corruption is suspected: run Disable-NetAdapterLso -Name "Ethernet" in PowerShell.

Step 5: Rebuild the Affected Stored Procedure or Query

  • If the error is isolated to a specific stored procedure, script it out and redeploy it to eliminate potential metadata corruption.
  • Test the exact same call using sqlcmd or SQL Server Management Studio (SSMS) 21 to confirm whether the issue is client-specific or server-side.

Alternative or Verification Steps

  • Verification: Re-run the failing operation from SSMS directly with the same MAX-type parameter values; if it succeeds in SSMS but fails in the application, the issue is confirmed to be driver/application-side.
  • Alternative: If the error persists only with a specific third-party driver, switch temporarily to Microsoft’s native OLE DB Driver 19 for SQL Server as a workaround while the vendor patches their chunking implementation.

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

Troubleshooting Guide: SQL Server Error 8008 – Parameter Mismatch in sp_execute

Why This Error Happens

This error occurs when a client application calls sp_execute with a parameter count that doesn’t match the parameter signature originally defined when the statement handle was created via sp_prepare or sp_prepexec. This mismatch is typically caused by application-layer caching of stale prepared statement handles, improperly configured ORM/driver parameter binding, or a race condition where the underlying query plan was altered (via schema change or recompilation) after the handle was prepared but before execution. It can also surface due to corrupted connection pooling states in ODBC or OLE DB drivers that reuse handles across sessions with differing parameter sets.

Step-by-Step Resolution Guide

Step 1: Clear the Prepared Statement Cache

  • Identify the application or driver maintaining the stale handle (common in ODBC, JDBC, and OLE DB connection pools).
  • Run DBCC FREEPROCCACHE on the affected database to force SQL Server to discard existing cached execution plans.
  • If using connection pooling, restart the application pool (IIS) or recycle the service to flush client-side cached handles.

Step 2: Audit the Application Code for Parameter Binding

  • Review the data access layer (e.g., Entity Framework, JDBC PreparedStatement, ODBC SQLBindParameter) to confirm the number of bound parameters matches the SQL query placeholders exactly.
  • Check for dynamic SQL generation where parameters may be conditionally added or removed between the sp_prepare call and the sp_execute call.
  • Ensure no code path mutates the parameter array between preparation and execution, especially in multi-threaded or async scenarios.

Step 3: Update SQL Server Native Client / ODBC Driver

  • On Windows Server 2025 / Windows 11, navigate to Control Panel > Programs > Programs and Features and verify the installed driver version (e.g., “Microsoft ODBC Driver 18 for SQL Server”).
  • Download and install the latest driver from the official Microsoft Download Center to resolve known handle-caching bugs.
  • Update connection strings to explicitly reference the updated driver version if multiple versions are installed side-by-side.

Step 4: Disable Statement Caching Temporarily (Diagnostic)

  • In your connection string, set Max Pool Size appropriately and disable statement caching (e.g., in JDBC: prepStmtCacheSize=0) to isolate whether the issue is caused by client-side caching.
  • Reproduce the error with caching disabled; if the error disappears, the root cause is confirmed as a stale handle issue rather than a server-side bug.
  • Re-enable caching only after confirming parameter binding logic is corrected in Step 2.

Step 5: Apply the Latest SQL Server 2025 Cumulative Update

  • Open SQL Server Configuration Manager and check the current build version under Help > About in SSMS.
  • Download the latest Cumulative Update (CU) from the Microsoft SQL Server servicing page, as this error has known fixes in specific builds related to the query optimizer’s handling of parameterized plans.
  • Apply the update during a maintenance window and restart the SQL Server service (net stop MSSQLSERVER / net start MSSQLSERVER).

Alternative or Verification Steps

  • Verify the fix by running the application’s failing transaction in a loop under load (e.g., 100 iterations) using SQL Server Profiler or Extended Events to confirm Error 8008 no longer appears in the sqlserver.error_reported event.
  • If the error persists after driver and application updates, bypass sp_prepare/sp_execute entirely by switching the application to use sp_executesql with explicitly defined parameters for the affected query as a stable workaround.

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

Troubleshooting Guide: SQL Server Error 8009 — Unknown TDS RPC Data Type

Why This Error Happens

This error occurs when the SQL Server Tabular Data Stream (TDS) parser receives a Remote Procedure Call (RPC) request containing a parameter data type token it does not recognize. This is typically caused by a version mismatch between the client driver (ODBC, OLE DB, or ADO.NET) and the SQL Server 2025 engine, where the client is sending a newer or deprecated data type that the server-side TDS interpreter cannot map correctly. It can also result from corrupted network packets, a malformed custom application payload, or an outdated driver that predates the TDS protocol revisions introduced in SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify and Update Client Driver Versions

  • Check the application’s connection string or driver manager to confirm which provider is in use (e.g., Microsoft OLE DB Driver for SQL Server, ODBC Driver 18, or Microsoft.Data.SqlClient).
  • Navigate to Control Panel > Programs and Features on Windows Server 2025 / Windows 11 and confirm the installed driver version.
  • Download and install the latest driver from the official Microsoft Download Center to ensure compatibility with the SQL Server 2025 TDS 8.0 protocol revision.

Step 2: Capture and Inspect the TDS Stream

  • Use SQL Server Profiler or Extended Events to capture the RPC:Starting and RPC:Completed events on the affected session.
  • Identify the exact parameter index referenced in the error message (the %d value) to pinpoint which column or variable is sending the invalid type.
  • Cross-reference the parameter’s data type against supported types listed in sys.types by running:
  SELECT name, system_type_id, user_type_id FROM sys.types;

Step 3: Validate Application-Level Parameter Binding

  • Review the application code (e.g., C#, Java, or Python) for any explicit parameter type casting using deprecated or custom enumerations.
  • Ensure that SqlDbType or equivalent enum values map directly to supported SQL Server 2025 types (avoid using raw integer type codes).
  • If using a third-party ORM (e.g., Entity Framework, Hibernate), update the SQL Server dialect/provider package to the latest release compatible with SQL Server 2025.

Step 4: Check for Network Packet Corruption

  • Run netsh int tcp show global on Windows Server 2025 to verify TCP Chimney/Offload settings aren’t corrupting packet payloads.
  • Temporarily disable TCP Checksum Offloading on the network adapter via Device Manager > Network Adapter Properties > Advanced to rule out hardware-level packet corruption.
  • Restart the SQL Server service after making network stack changes:
  Restart-Service -Name "MSSQLSERVER"

Step 5: Reinstall or Repair SQL Server Native Client Components

  • Open Programs and Features, select the SQL Server 2025 client tools, and choose Repair.
  • If the issue persists, fully uninstall and reinstall the client connectivity components using SQL Server Installation Media (setup.exe /ACTION=REPAIR).

Alternative or Verification Steps

  • To verify the fix, re-run the failing stored procedure or RPC call from the application and confirm no 8009 error appears in the SQL Server Error Log (Management > SQL Server Logs in SSMS).
  • As an alternative, bypass RPC-based execution temporarily by converting the call to a plain-text EXEC statement (ad-hoc SQL) to confirm whether the issue is isolated to RPC parameter binding specifically.

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

Troubleshooting Guide: TDS RPC Protocol Stream Error (Error 8005)

Why This Error Happens

This error occurs when the TDS (Tabular Data Stream) packet sent from a client application to SQL Server 2025 contains a malformed Remote Procedure Call (RPC) request, typically due to an invalid or mismatched parameter name being passed to a stored procedure. This is commonly caused by outdated or corrupted client-side drivers (ODBC/OLE DB) that incorrectly format the parameter metadata, or by a mismatch between the parameter names defined in the application code and the actual stored procedure signature on the server. In some cases, network packet corruption or an incompatible connection pooling configuration can also scramble the parameter data before it reaches the SQL Server engine.

Step-by-Step Resolution Guide

Step 1: Verify Stored Procedure Parameter Names

  • Open SQL Server Management Studio (SSMS) and run sp_helptext 'YourStoredProcedureName' to inspect the exact parameter names and data types.
  • Cross-reference these names with the parameter collection in your application code (e.g., C# SqlCommand.Parameters.Add) to ensure there are no typos or case-sensitivity mismatches (e.g., @UserID vs @UserId).
  • Ensure no extra or missing parameters are being sent compared to what the procedure expects.

Step 2: Update Client Drivers and Connection Libraries

  • Navigate to the Microsoft Download Center and update the Microsoft OLE DB Driver for SQL Server or ODBC Driver to the latest version compatible with SQL Server 2025.
  • On Windows Server 2025, check C:\Windows\System32\msodbcsql18.dll (or relevant driver path) to confirm the version via file properties.
  • Restart the application pool (if using IIS) or the client service to ensure the new driver DLLs are loaded into memory.

Step 3: Clear Procedure Cache and Recompile

  • Execute DBCC FREEPROCCACHE in a query window to clear potentially corrupted execution plans that might be referencing old parameter signatures.
  • Force a recompile of the specific stored procedure using EXEC sp_recompile 'YourStoredProcedureName'.
  • Re-run the application query to see if the RPC stream is accepted correctly.

Step 4: Check for Network Packet Corruption

  • Open Event Viewer on Windows Server 2025 and check the System logs for any underlying TCP/IP or NIC driver errors occurring simultaneously with Error 8005.
  • If found, update the Network Interface Card (NIC) drivers via Device Manager or disable TCP Chimney Offload using PowerShell: Disable-NetAdapterChecksumOffload -Name "*".
  • Re-test the connection to rule out hardware-level packet corruption.

Alternative or Verification Steps

  • Verification: Run a SQL Server Profiler trace (or Extended Events session) filtered for RPC:Starting and RPC:Completed events to visually confirm the parameters are now being passed correctly without triggering Error 8005.
  • Alternative: If the error persists only in a specific application, bypass the ORM (Object-Relational Mapper) layer temporarily and execute the stored procedure directly via a raw SqlCommand to isolate whether the bug lies in the ORM’s parameter-mapping logic or the database schema itself.

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

Troubleshooting Guide: TDS Protocol Error 8006 (Invalid Parameter Status Flags)

Why This Error Happens

This error occurs when the SQL Server Tabular Data Stream (TDS) parser receives a Remote Procedure Call (RPC) request where the parameter metadata does not conform to the expected protocol specification, typically because the status flag byte contains unrecognized or malformed bit values. This is most commonly caused by a mismatched or outdated client driver (such as an older ODBC or OLE DB provider) communicating with SQL Server 2025, a corrupted network packet during transmission, or a custom application incorrectly constructing the TDS stream manually instead of relying on a standard driver. In rare cases, this can also result from a mismatch in TDS protocol versions between client and server after an in-place upgrade on Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify and Update Client Drivers

  • Confirm the client application is using a TDS 8.0-compliant driver (Microsoft ODBC Driver 18+ or OLE DB Driver 19+ for SQL Server).
  • Check driver version via Control Panel > ODBC Data Sources > Drivers tab on Windows 11/Server 2025.
  • Download and install the latest driver from the official Microsoft Download Center if versions are outdated.
  • Restart the client application after installation to ensure the new driver DLLs are loaded.

Step 2: Capture and Inspect the TDS Stream

  • Use SQL Server Profiler or Extended Events to capture the exact RPC:Starting event triggering the error.
  • Run the following query to enable a lightweight trace session:
  CREATE EVENT SESSION [TDS_Debug] ON SERVER 
  ADD EVENT sqlserver.rpc_starting 
  ADD TARGET package0.event_file(SET filename=N'C:\Temp\TDS_Debug.xel');
  ALTER EVENT SESSION [TDS_Debug] ON SERVER STATE = START;
  • Review the captured parameter payload to identify which specific parameter index (%d) is sending the invalid flag.

Step 3: Check Network Integrity and Packet Size

  • Navigate to SQL Server Configuration Manager > SQL Server Network Configuration > Protocols.
  • Ensure “Force Encryption” settings match between client and server to prevent packet corruption during the handshake.
  • Reset the Network Packet Size to the default (4096) if it has been manually altered in the connection string, as oversized packets can corrupt RPC parameter boundaries.

Step 4: Rebuild the Application’s Parameter Collection

  • If using a custom application (e.g., via SqlCommand in .NET or a third-party ETL tool), verify that parameter SqlDbType matches the exact data type expected by the stored procedure.
  • Remove any manually set IsNullable or Direction flags that might be conflicting with the driver’s automatic serialization.
  • Re-deploy the application after clearing the obj and bin folders to ensure no stale metadata DLLs are referenced.

Alternative or Verification Steps

  • Verification: Execute the specific stored procedure manually via SQL Server Management Studio (SSMS) using the exact parameter values logged in the Extended Events trace; if it succeeds here but fails in the app, the issue is confirmed to be driver-side serialization.
  • Alternative: If the error persists only on specific endpoints, bypass the issue by switching the connection protocol from “Named Pipes” to “TCP/IP” in the SQL Server Configuration Manager, as this often resolves stream corruption issues specific to legacy protocol stacks.

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

Troubleshooting Guide: SQL Server Error 8003 – “Too Many Parameters”

Why This Error Happens

This error occurs when a query, stored procedure call, or parameterized request sent to SQL Server 2025 exceeds the maximum allowed parameter count (typically 2,100 parameters per request). It is most commonly triggered by ORM frameworks (like Entity Framework or Dapper) that auto-generate large IN clauses or bulk insert statements dynamically, pushing past the hard-coded TDS protocol limit. This is a client-side query design issue rather than a server configuration failure, but it can also surface due to poorly optimized dynamic SQL generation on the application layer.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Enable SQL Server Profiler or Extended Events on Windows Server 2025 to capture the exact query triggering Error 8003.
  • Check Application Event Viewer logs located at Event Viewer > Windows Logs > Application and filter by Event ID 8003 for correlated timestamps.
  • Review application logs (e.g., EF Core logs) to identify if a WHERE column IN (@p1, @p2, ... @pN) pattern is being generated.

Step 2: Reduce Parameter Count in the Query

  • Refactor large IN clauses to use a Table-Valued Parameter (TVP) instead of individual parameters.
  • Example fix using TVP in T-SQL:
  CREATE TYPE dbo.IntList AS TABLE (ID INT);
  • Modify application code to pass a single DataTable or List<int> as a TVP rather than looping through individual parameter bindings.
  • For bulk inserts, batch the operation into smaller chunks (e.g., 500 rows per batch) instead of a single massive INSERT statement.

Step 3: Adjust ORM or Application-Level Batch Size

  • If using Entity Framework Core, explicitly set MaxBatchSize in your DbContext configuration:
  optionsBuilder.UseSqlServer(connectionString, 
      options => options.MaxBatchSize(100));
  • If using Dapper or raw ADO.NET, manually chunk large collections before executing SqlCommand.ExecuteNonQuery().
  • Restart the application pool (IIS) or the .NET service on Windows 11/Windows Server 2025 to apply configuration changes.

Step 4: Validate Connection String and Driver Version

  • Ensure you are using the latest Microsoft.Data.SqlClient driver, as older drivers may not properly batch TVPs.
  • Update via NuGet Package Manager:
  Update-Package Microsoft.Data.SqlClient
  • Confirm the connection string does not force legacy TDS protocol versions that limit optimization features.

Alternative or Verification Steps

  • Re-run the original failing query/application workflow and confirm Error 8003 no longer appears in SQL Server Error Logs located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • If the error persists, temporarily log the generated SQL command text (via SqlCommand.CommandText) before execution to manually count parameters and confirm you are under the 2,100 threshold.

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

Troubleshooting Guide: SQL Server Error 8004 – Invalid TDS RPC Protocol Stream

Why This Error Happens

This error typically occurs when the Tabular Data Stream (TDS) packet sent by a client application contains a malformed Remote Procedure Call (RPC) request, often due to a mismatched or outdated client driver communicating with SQL Server 2025. It can also result from a corrupted network packet during transmission, a third-party connection pooling tool improperly formatting the RPC call name, or an application calling a stored procedure with an invalid or truncated name due to encoding issues. Additionally, mixed TLS/encryption configurations between the client and Windows Server 2025 can corrupt the stream before SQL Server parses it.

Step-by-Step Resolution Guide

Step 1: Verify and Update Client Drivers

  • Confirm the application is using an ODBC, OLE DB, or SqlClient driver version certified for SQL Server 2025 (e.g., Microsoft.Data.SqlClient 5.x or later).
  • Check driver version via Control Panel > ODBC Data Sources > Drivers tab on Windows Server 2025 / Windows 11.
  • Update outdated drivers using the latest Microsoft OLE DB Driver or ODBC Driver installer from the official Microsoft Download Center.

Step 2: Inspect the RPC Call and Stored Procedure Name

  • Review the application code or query logs to identify the exact RPC call being sent (use SQL Server Profiler or Extended Events to capture RPC:Starting events).
  • Check for invalid characters, excessive length, or incorrect schema prefixes (e.g., dbo.sp_GetData vs. sp_GetData) in the stored procedure name.
  • Validate that the stored procedure actually exists in the target database using:
  SELECT * FROM sys.objects WHERE type = 'P' AND name = 'YourProcedureName';

Step 3: Reset Network and Encryption Settings

  • Open SQL Server Configuration Manager and navigate to SQL Server Network Configuration > Protocols for MSSQLSERVER.
  • Ensure TCP/IP is enabled and that encryption settings match between client and server (check Force Encryption under the Flags tab).
  • Restart the SQL Server service after applying changes:
  Restart-Service -Name 'MSSQLSERVER'

Step 4: Clear Connection Pooling and Application Cache

  • If using a connection pooling library (e.g., ADO.NET, JDBC), disable pooling temporarily to rule out stale or corrupted pooled connections.
  • Restart the application pool (for IIS-hosted apps) via:
  Restart-WebAppPool -Name "YourAppPoolName"
  • Clear any cached query plans on SQL Server using:
  DBCC FREEPROCCACHE;

Alternative or Verification Steps

  • Re-run the failing operation and monitor SQL Server Error Logs (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) to confirm Error 8004 no longer appears.
  • If the issue persists, capture a network trace using Wireshark or SQL Server Extended Events to inspect the raw TDS packet structure and confirm the RPC name is transmitted correctly end-to-end.

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

Troubleshooting Guide: TDS RPC Protocol Error 8001 (Invalid Meta-Information for Sql Variant Parameter)

Why This Error Happens

This error occurs when a client application sends a Remote Procedure Call (RPC) to SQL Server 2025 with malformed metadata describing a sql_variant parameter within the Tabular Data Stream (TDS) protocol. Typically, this is caused by an outdated or mismatched client driver (such as an older ODBC or OLE DB provider) that does not correctly serialize the base type and length information required for sql_variant data. It can also result from a corrupted client-side connection library or a custom application incorrectly constructing the parameter payload before transmission.

Step-by-Step Resolution Guide

Step 1: Update the Client Connectivity Drivers

  • Verify the version of the driver being used (ODBC Driver, OLE DB, or SqlClient) on the machine initiating the connection.
  • Download and install the latest Microsoft ODBC Driver for SQL Server compatible with SQL Server 2025.
  • Restart the application service or IIS app pool to ensure the new driver DLLs are loaded into memory.

Step 2: Audit the Application Code for Sql Variant Handling

  • Review the data access layer code where parameters are defined, specifically looking for SqlDbType.Variant assignments.
  • Ensure that the application explicitly casts the value and defines a BaseType before adding it to the SqlParameter collection.
  • Check for any custom TDS packet manipulation or legacy libraries that might be stripping metadata headers from the request.

Step 3: Validate SQL Server Instance Configuration

  • Open SQL Server Configuration Manager and verify the “SQL Server Network Configuration” protocols are correctly enabled (TCP/IP, Named Pipes).
  • Check for mismatched TDS versions between legacy linked servers and the SQL Server 2025 instance.
  • Run DBCC CHECKDB to rule out underlying system table corruption that might affect metadata catalog views used during parameter binding.

Step 4: Capture a Network Trace for Deep Analysis

  • Use SQL Server Profiler or Extended Events to capture the specific RPC:Starting event associated with the failing Session ID.
  • Filter the trace by the Error column matching 8001 to isolate the exact byte stream being sent.
  • Cross-reference the captured TDS stream with the TDS protocol documentation to identify which specific byte in the variant header is malformed.

Alternative or Verification Steps

  • Verification: Re-run the specific stored procedure or query that triggered the error using SQL Server Management Studio (SSMS) with the native client to confirm the server-side logic is sound; if it succeeds in SSMS but fails in the app, the issue is confirmed to be client-side serialization.
  • Alternative: If updating drivers is not immediately possible, modify the application to explicitly cast the variable to a standard data type (e.g., NVARCHAR or INT) instead of sql_variant as a temporary workaround to bypass the parsing bug.

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

Troubleshooting Guide: TDS RPC Error 8002 (Invalid XML Database or Schema)

Why This Error Happens

This error occurs when a client application sends an RPC call containing an XML-typed parameter that references a database or schema collection that SQL Server 2025 cannot resolve in the current connection context. Typically, this happens because the XML schema collection was defined in a different database than the one the session is currently using, the schema collection name is misspelled or was dropped, or the client-side driver (ODBC/OLE DB/ADO.NET) is sending malformed metadata for the XML parameter. It can also surface after an in-place upgrade to SQL Server 2025 if legacy TDS client libraries are not fully compatible with updated XML type-handling in the RPC stream.

Step-by-Step Resolution Guide

Step 1: Verify the XML Schema Collection Exists and Is Scoped Correctly

  • Run SELECT * FROM sys.xml_schema_collections; in the target database to confirm the schema collection referenced by the parameter actually exists.
  • Confirm you are querying the correct database context — XML schema collections are database-scoped, not server-scoped, so a collection in DB_A will not resolve if the session context is DB_B.
  • Check the three-part naming convention in the client call (e.g., dbo.MySchemaCollection) and ensure the schema owner matches.

Step 2: Inspect and Correct the Client Connection String / Context

  • Ensure the client application explicitly sets the correct Initial Catalog (database) in the connection string before issuing RPC calls with XML parameters.
  • For applications using USE [DatabaseName]; statements dynamically, confirm this executes successfully before the XML parameter is bound.
  • If using ADO.NET, verify the SqlParameter for the XML type explicitly specifies SqlDbType.Xml and does not pass an unqualified or null schema collection name.

Step 3: Update SQL Server Client Drivers and Native Client Libraries

  • On Windows Server 2025 / Windows 11, update to the latest Microsoft OLE DB Driver or ODBC Driver for SQL Server, as older TDS libraries may mishandle XML type metadata introduced in SQL Server 2025.
  • 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 patch the driver via the Microsoft Download Center if version mismatches are found.

Step 4: Rebuild or Re-register the XML Schema Collection

  • If the schema collection appears corrupted or was partially migrated during an upgrade, drop and recreate it:
  DROP XML SCHEMA COLLECTION dbo.MySchemaCollection;
  CREATE XML SCHEMA COLLECTION dbo.MySchemaCollection AS N'<schema XML definition here>';
  • Re-grant necessary permissions using GRANT REFERENCES ON XML SCHEMA COLLECTION::dbo.MySchemaCollection TO [UserOrRole];.

Alternative or Verification Steps

  • Use SQL Server Profiler or Extended Events to capture the exact RPC call and confirm the parameter now resolves to a valid, existing schema collection in the correct database context.
  • If the error persists, bypass typed XML schema validation temporarily by casting the parameter to untyped XML (XML without a schema collection) to confirm whether the schema binding itself is the root cause.

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

Why This Error Happens

Error 7998 is generated by DBCC CHECKIDENT when SQL Server 2025 reports the current identity value of a table during a consistency check. While often informational, it surfaces as an error when the stored identity value in the metadata does not match the actual maximum value present in the identity column, usually due to improper shutdowns, bulk insert operations with IDENTITY_INSERT, or replication conflicts. This mismatch can also occur after a database restore or attach operation where the transaction log did not fully commit the last known identity seed, leaving the internal counter corrupted or out of sync.

Step-by-Step Resolution Guide

Step 1: Verify the Current Identity Value Discrepancy

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run DBCC CHECKIDENT ('YourTableName', NOCHECK) to view the current value without making changes.
  • Compare this output against SELECT MAX(IdentityColumn) FROM YourTableName to confirm a mismatch exists.

Step 2: Reseed the Identity Column Manually

  • Execute DBCC CHECKIDENT ('YourTableName', RESEED, NewSeedValue) where NewSeedValue matches the actual max value found in Step 1.
  • If the table is empty but the identity value persists incorrectly, reseed to 0 using DBCC CHECKIDENT ('YourTableName', RESEED, 0).
  • Ensure no active transactions are writing to the table during this operation to avoid race conditions.

Step 3: Check for Underlying Log or Metadata Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS to rule out broader corruption issues in Windows Server 2025 environments, particularly after a forced shutdown.
  • Review the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for related I/O warnings preceding the 7998 event.
  • If corruption is found, restore the database from the last known good backup rather than relying solely on reseeding.

Step 4: Update SQL Server 2025 Cumulative Updates

  • Navigate to the Microsoft Update Catalog and verify you are running the latest Cumulative Update (CU) for SQL Server 2025, as early builds have known identity-caching bugs with the new Accelerated Database Recovery (ADR) engine.
  • Apply the update via Setup.exe in silent mode if managing multiple Windows Server 2025 nodes: Setup.exe /q /ACTION=Patch /INSTANCENAME=MSSQLSERVER /IACCEPTSQLSERVERLICENSETERMS.

Alternative or Verification Steps

  • After reseeding, insert a test row without specifying the identity value and confirm the new row increments correctly based on the reseeded number.
  • If the error persists immediately after a reseed, disable and re-enable Accelerated Database Recovery (ADR) via ALTER DATABASE YourDatabaseName SET ACCELERATED_DATABASE_RECOVERY = OFF; followed by ON; to clear the persistent version store cache.

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

Troubleshooting Guide: Error 7999 – Could Not Find Index on Table (SQL Server)

Why This Error Happens

This error occurs when a T-SQL statement, stored procedure, or application references an index name that does not exist on the specified table or view, typically because the index was dropped, renamed, or never created in the current database context. It can also surface after a database restore or migration where index metadata was not fully synchronized, or when a hint (e.g., WITH (INDEX(index_name))) points to an outdated index name. In rare cases, this is a symptom of underlying system catalog corruption in sys.indexes.

Step-by-Step Resolution Guide

Step 1: Verify the Index Actually Exists

  • Open SQL Server Management Studio (SSMS) and connect to the SQL Server 2025 instance.
  • Run the following query to check existing indexes on the table:
  SELECT name AS IndexName, type_desc 
  FROM sys.indexes 
  WHERE object_id = OBJECT_ID('YourSchema.YourTableName');
  • Confirm whether the index name referenced in the error (e.g., in a query hint or script) matches exactly, including case sensitivity if the instance uses a case-sensitive collation.

Step 2: Correct the Query, Procedure, or Index Hint

  • Locate the offending script, stored procedure, or application code referencing the missing index.
  • Update the WITH (INDEX(...)) hint or DBCC command to use the correct, currently existing index name.
  • If the index was intentionally renamed, use sp_rename to restore the expected name:
  EXEC sp_rename 'YourSchema.YourTableName.OldIndexName', 'NewIndexName', 'INDEX';

Step 3: Recreate the Missing Index

  • If the index was dropped unintentionally (e.g., during a maintenance job or deployment script), recreate it manually:
  CREATE NONCLUSTERED INDEX IX_YourIndexName 
  ON YourSchema.YourTableName (ColumnName);
  • Check deployment scripts, DACPAC packages, or SSDT projects for index definitions that may have been excluded during the last deployment cycle.

Step 4: Check for Post-Migration or Restore Metadata Issues

  • If this error appeared after a database restore or migration to Windows Server 2025, run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORS; to rule out catalog corruption.
  • Review the SQL Server Error Log (%ProgramFiles%\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related corruption or metadata warnings around the same timestamp.

Step 5: Update Statistics and Refresh Cached Plans

  • Run sp_updatestats on the affected database to refresh index/statistics metadata.
  • Clear cached execution plans referencing the old index with:
  DBCC FREEPROCCACHE;

Alternative or Verification Steps

  • Re-run the original query or application process that triggered Error 7999 and confirm it executes without referencing a missing index.
  • If the error persists, use sp_helpindex 'YourTableName' to cross-check all valid index names, and restore the table from the last known good backup if metadata corruption is confirmed via DBCC CHECKDB.

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

Troubleshooting Guide: SQL Server Error 7995

Why This Error Happens

Error 7995 occurs when DBCC CHECKDB (or a related consistency-checking command) detects that the system catalog tables themselves—such as sys.sysschobjs, sys.sysrowsets, or other base system tables—contain structural inconsistencies. Because DBCC relies on accurate system catalog metadata to map out and validate user objects, it cannot safely continue scanning the rest of the database once the catalog itself is untrustworthy. This typically stems from underlying storage corruption (disk errors, faulty I/O subsystem, improper shutdown), a damaged transaction log replay, or hardware-level bit flips affecting system pages.

Step-by-Step Resolution Guide

Step 1: Isolate and Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; from SQL Server Management Studio (SSMS) or sqlcmd to capture the full list of errors beyond 7995.
  • Check the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for related I/O or storage warnings (e.g., Event ID 823, 824, or 825).
  • Note whether corruption is isolated to system catalogs only or also affects user tables/indexes.

Step 2: Check Hardware and Storage Health

  • Open Event Viewer on Windows Server 2025 / Windows 11 and inspect the System log under Windows Logs > System for Disk or NTFS warnings.
  • Run chkdsk C: /f /r (or the appropriate data drive letter) in an elevated Command Prompt to scan for and repair file system-level errors.
  • Validate SAN/NAS or virtual disk health if running on a VM (Hyper-V, VMware) by checking the hypervisor’s storage event logs.

Step 3: Restore from a Known-Good Backup

  • Since system catalog corruption often cannot be repaired without data loss, prioritize restoring the most recent clean full backup plus transaction log backups.
  • Use RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDatabaseName.bak' WITH REPLACE, RECOVERY; in SSMS.
  • Immediately run DBCC CHECKDB again post-restore to confirm no inconsistencies remain.

Step 4: Attempt Emergency Repair (Only if No Valid Backup Exists)

  • Place the database in emergency mode: ALTER DATABASE YourDatabaseName SET EMERGENCY;
  • Set single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS; understanding this may delete corrupted rows/pages to restore catalog consistency.
  • Return the database to multi-user mode: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Step 5: Review and Patch SQL Server Build

  • Confirm you are running the latest Cumulative Update (CU) for SQL Server 2025 via SELECT @@VERSION;.
  • Download and apply the latest CU from the Microsoft Update Catalog to rule out any known catalog-handling bugs.

Alternative or Verification Steps

  • After remediation, re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm the output returns 0 allocation errors and 0 consistency errors.
  • If corruption recurs shortly after repair, treat it as a hardware-level issue — run full memory diagnostics (mdsched.exe) and a vendor-specific disk health check tool before reintroducing the database to production.

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

Troubleshooting Guide: Error 7996 – Extended Stored Procedures Can Only Be Created in the Master Database

Why This Error Happens

Error 7996 occurs when a user attempts to execute sp_addextendedproc or CREATE PROCEDURE ... EXTERNAL NAME while their current session context is pointed at a user database instead of master. SQL Server 2025 enforces this restriction because extended stored procedures (XPs) bind directly to DLL files loaded into the SQL Server process space, and allowing registration outside of master creates security and dependency-tracking risks. This is typically a context/scope issue rather than a permissions or corruption problem, though insufficient sysadmin rights can also trigger a related access failure.

Step-by-Step Resolution Guide

Step 1: Verify Your Current Database Context

  • Run SELECT DB_NAME(); in SQL Server Management Studio (SSMS) to confirm which database is active.
  • If the result is not master, this confirms the root cause of Error 7996.
  • Check the SSMS database dropdown in the toolbar, as it often defaults to the last-used user database.

Step 2: Switch Context to the Master Database

  • Execute USE master; as the first line in your query window before running the extended procedure command.
  • Re-run your original command, for example:
  USE master;
  GO
  EXEC sp_addextendedproc 'xp_yourproc', 'yourlibrary.dll';
  • Ensure no implicit USE [YourDatabase] statement exists earlier in the script or in a referenced template.

Step 3: Confirm Sysadmin Role Membership

  • Open SSMS and navigate to Security > Logins > [YourLogin] > Server Roles.
  • Confirm the sysadmin fixed server role checkbox is selected, since only sysadmins can register extended procedures.
  • Alternatively, run: SELECT IS_SRVROLEMEMBER('sysadmin'); — a return value of 1 confirms membership.

Step 4: Validate DLL Placement and Path

  • Place the extended procedure DLL file inside the Binn directory of your SQL Server instance (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\).
  • Ensure the SQL Server service account has Read & Execute NTFS permissions on this folder.
  • Avoid specifying a full UNC or absolute path in sp_addextendedproc; use only the filename if the DLL resides in Binn.

Step 5: Restart SQL Server Service to Clear Cached Bindings

  • 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 stale DLL load locks that may interfere with re-registration attempts.

Alternative or Verification Steps

  • Verify success by running SELECT * FROM sys.sysobjects WHERE xtype = 'X'; while connected to master — your newly registered XP should appear in the list.
  • If the error persists, migrate the extended procedure to a native CLR Integration stored procedure instead, as Microsoft has deprecated classic XPs in favor of CLR assemblies for improved sandboxing and cross-database flexibility.

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

Troubleshooting Guide: Error 7997 — “‘%.*ls’ does not contain an identity column”

Why This Error Happens

This error occurs when a T-SQL statement attempts to use an identity-specific function or command—such as DBCC CHECKIDENT, SET IDENTITY_INSERT, or IDENT_CURRENT—against a table that was never created with an IDENTITY property on any of its columns. SQL Server 2025 validates the table’s metadata before executing these operations, and if no column has the identity attribute set, the engine immediately rejects the request rather than silently ignoring it. This is commonly triggered by schema drift, where a table was recreated or altered (dropping the identity column) but dependent scripts, ETL jobs, or application code were never updated to reflect the change.

Step-by-Step Resolution Guide

Step 1: Verify the Table’s Actual Schema

  • Run the following query to inspect the table definition and confirm whether an identity column exists:
  SELECT name, is_identity FROM sys.columns WHERE object_id = OBJECT_ID('YourSchema.YourTable');
  • If is_identity returns 0 for all rows, the table genuinely lacks an identity column, confirming the root cause.

Step 2: Identify the Offending Script or Application Call

  • Search recent deployment scripts, stored procedures, or ETL packages (SSIS/ADF) for calls like DBCC CHECKIDENT('YourTable'), SET IDENTITY_INSERT YourTable ON, or IDENT_CURRENT('YourTable').
  • Cross-reference with SQL Server error logs located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG to find the exact statement and timestamp that triggered Error 7997.
  • Use SQL Server Profiler or Extended Events (sqlserver.error_reported) to capture the exact batch text in real time if the error is intermittent.

Step 3: Correct the Schema or the Script

  • If the table should have an identity column (e.g., it was accidentally dropped during a migration), add it back using:
  ALTER TABLE YourSchema.YourTable ADD NewIDColumn INT IDENTITY(1,1);
  • Note: This requires recreating the table in most cases, as SQL Server does not allow adding an identity column directly to an existing table with data via simple ALTER TABLE ADD.
  • Alternatively, create a new table with the identity column, migrate data using SET IDENTITY_INSERT, then rename tables via sp_rename.
  • If the table is not supposed to have an identity column, update the application code or script to remove the invalid DBCC CHECKIDENT / SET IDENTITY_INSERT call entirely.

Step 4: Redeploy and Restart Dependent Services

  • Push the corrected script or schema change through your deployment pipeline (e.g., Azure DevOps, SSMS Change Script).
  • Restart the SQL Server Agent service via services.msc on Windows Server 2025 if the error originated from a scheduled job, ensuring cached execution plans are cleared.

Alternative or Verification Steps

  • Re-run the original failing command or job manually in SSMS against the corrected table; a successful execution with no Error 7997 confirms the fix.
  • If the error persists, check for synonym or linked server references pointing to a different (non-identity) table with the same name in another schema or database, using sys.synonyms and sys.servers.

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

Troubleshooting Guide: SQL Server Error 7993

Why This Error Happens

Error 7993 occurs when you attempt to shrink a database file to a target size (in pages) that is smaller than the number of pages currently in use or already allocated at a minimum by SQL Server. This typically happens because the DBCC SHRINKFILE command was issued with a target size parameter that conflicts with the file’s current allocation, or because the file contains active data, indexes, or log records that cannot be deallocated below the requested threshold. It can also occur if a concurrent process is actively writing to the file, preventing SQL Server from recalculating the minimum required page count accurately.

Step-by-Step Resolution Guide

Step 1: Verify Current File Size and Usage

  • Open SQL Server Management Studio (SSMS) and connect to the target instance.
  • Run the following query to check actual space used versus allocated space:
USE [YourDatabaseName];
GO
SELECT name, size, FILEPROPERTY(name, 'SpaceUsed') AS SpaceUsed
FROM sys.database_files;
  • Confirm the size value (in 8KB pages) against the target shrink value you specified; ensure your target is not lower than SpaceUsed.

Step 2: Adjust the Shrink Target Size

  • Instead of specifying an arbitrary target size, use a calculated value based on current usage.
  • Run DBCC SHRINKFILE with a target size that is equal to or slightly larger than the SpaceUsed value retrieved in Step 1:
DBCC SHRINKFILE (N'YourLogicalFileName', TargetSizeInMB);
  • If shrinking the log file, ensure a transaction log backup has been taken first to clear inactive VLFs (Virtual Log Files).

Step 3: Check for Blocking Transactions or Replication

  • Open the Activity Monitor in SSMS (Right-click Server Instance > Activity Monitor) to check for long-running transactions preventing deallocation.
  • Run sp_who2 to identify any sessions holding locks on the specific database.
  • If using Transactional Replication or Always On Availability Groups, verify that the Log Reader Agent has processed all transactions, as undelivered transactions can prevent log truncation and shrinking.

Step 4: Rebuild Indexes to Consolidate Space

  • If the shrink operation continues to fail due to fragmentation, rebuild the indexes to consolidate used pages into a contiguous block, which can sometimes resolve conflicts with minimum page counts.
  • Execute the following on the specific table or across the database:
ALTER INDEX ALL ON YourTableName REBUILD;
  • Re-attempt the DBCC SHRINKFILE command after the rebuild completes.

Alternative or Verification Steps

  • Verify the Fix: Re-run the sys.database_files query from Step 1. The size column should now reflect the new, smaller value without throwing Error 7993.
  • Alternative Solution: If the error persists specifically on the Primary Data File (PRIMARY), consider using DBCC SHRINKFILE (N'FileName', EMPTYFILE) to migrate data to other files in the filegroup (if applicable) before attempting a final shrink.

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

Troubleshooting Guide: Error 7994 — DBCC CheckDatabase Skipped on Resource Database

Why This Error Happens

This error occurs because the login executing DBCC CHECKDB does not have sufficient permissions to validate the hidden resource database (mssqlsystemresource), which requires sysadmin-level access or direct dedicated administrator connection (DAC) rights. SQL Server 2025 intentionally restricts access to the resource database since it contains system objects, and standard db_owner or limited sysadmin-delegated roles are not enough to trigger an integrity scan on it. This typically surfaces during scheduled maintenance plans or third-party monitoring tools running under a service account lacking full sysadmin membership.

Step-by-Step Resolution Guide

Step 1: Verify the Executing Login’s Role Membership

  • Open SQL Server Management Studio (SSMS) and connect using an account known to have sysadmin rights.
  • Run the following query to check the role of the account triggering the job:
  SELECT sp.name, sp.type_desc, r.name AS role_name
  FROM sys.server_principals sp
  JOIN sys.server_role_members rm ON sp.principal_id = rm.member_principal_id
  JOIN sys.server_principals r ON rm.role_principal_id = r.principal_id
  WHERE sp.name = 'DOMAIN\ServiceAccount';
  • Confirm whether sysadmin is listed; if not, this confirms the root cause.

Step 2: Grant Sysadmin Role to the SQL Server Agent Service Account

  • Launch SSMS and navigate to Security > Logins.
  • Right-click the login used by SQL Server Agent (or the maintenance plan proxy account) and select Properties.
  • Under Server Roles, check the box for sysadmin and click OK.
  • Alternatively, run this T-SQL command:
  ALTER SERVER ROLE sysadmin ADD MEMBER [DOMAIN\ServiceAccount];

Step 3: Validate Access via the Dedicated Administrator Connection (DAC)

  • Open a new query window in SSMS and connect using the syntax ADMIN:ServerName to force a DAC session.
  • Run DBCC CHECKDB('mssqlsystemresource') WITH NO_INFOMSGS, ALL_ERRORMSGS; manually to confirm the resource database is now accessible.
  • If the DAC connection fails, ensure the “Remote Admin Connections” setting is enabled via sp_configure 'remote admin connections', 1; followed by RECONFIGURE;.

Step 4: Restart the SQL Server Agent Service

  • Open Services.msc on Windows Server 2025.
  • Locate SQL Server Agent (MSSQLSERVER), right-click, and select Restart.
  • This ensures the newly applied permissions are refreshed in the service’s active session token.

Alternative or Verification Steps

  • Re-run the full database integrity check job and monitor the SQL Server Error Log (via EXEC sp_readerrorlog;) to confirm Error 7994 no longer appears.
  • If elevating to sysadmin is against company security policy, configure a separate maintenance job specifically for the resource database that runs under the sa account or a certificate-signed stored procedure with elevated permissions scoped only to DBCC CHECKDB.

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

Troubleshooting Guide: SQL Server Error 7991 — Missing Dictionary on Clustered Columnstore Index

Why This Error Happens

Error 7991 occurs when the dictionary structures backing a columnstore rowgroup become corrupted or go missing, typically due to disk-level corruption, improper shutdowns, or storage subsystem failures that affected the underlying .ndf/.mdf data files. This can also happen when a crash occurs mid-compression during a tuple-mover or bulk-load operation, leaving the columnstore segment in an inconsistent state. Because dictionaries are required to decode encoded column values in compressed rowgroups, SQL Server cannot read the affected rowgroup and flags the index as damaged.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS, ALL_ERRORMSGS; to identify whether corruption is isolated to the columnstore index or spans multiple objects.
  • Check the SQL Server error log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for correlating I/O or storage warnings around the same timestamp.
  • Note the exact table name, index name, column ID, and rowgroup ID reported in the error message for targeted remediation.

Step 2: Attempt Index-Level Repair

  • Try rebuilding only the affected index first, since a full rebuild can sometimes regenerate the dictionary: ALTER INDEX [YourCCI_IndexName] ON [dbo].[YourTable] REBUILD;
  • If the rebuild fails or hangs, drop and recreate the clustered columnstore index entirely: DROP INDEX [YourCCI_IndexName] ON [dbo].[YourTable]; followed by CREATE CLUSTERED COLUMNSTORE INDEX [YourCCI_IndexName] ON [dbo].[YourTable];
  • Monitor sys.dm_db_column_store_row_group_physical_stats to confirm the rowgroup state changes from TOMBSTONE or INVISIBLE to COMPRESSED.

Step 3: Restore from a Known-Good Backup

  • If rebuild fails due to unreadable data pages, restore the affected database (or just the filegroup, if partitioned) from the most recent verified full backup: RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDatabase_Full.bak' WITH NORECOVERY;
  • Apply subsequent differential and transaction log backups in sequence, finishing with WITH RECOVERY on the final log restore.
  • Validate backup integrity beforehand using RESTORE VERIFYONLY FROM DISK = 'D:\Backups\YourDatabase_Full.bak'; to avoid restoring a backup that already contains the corruption.

Step 4: Investigate and Resolve Underlying Storage Issues

  • Check Windows Event Viewer (Windows Logs > System) for Disk or NTFS warnings (Event IDs 7, 11, 51) that indicate failing storage hardware or driver issues.
  • Run chkdsk D: /f /r on the volume hosting the SQL Server data files to repair file system-level errors (schedule offline if the volume is in use).
  • If using virtualized or SAN storage, confirm write-caching policies and ensure disk controllers have battery-backed cache enabled to prevent future write-interruption corruption.

Alternative or Verification Steps

  • After remediation, re-run DBCC CHECKDB and query sys.dm_db_column_store_row_group_physical_stats to confirm no rowgroups report state_desc = 'TOMBSTONE' or errors on the previously affected table.
  • If no clean backup exists and rebuild fails, export the readable data via bcp or SELECT INTO a new staging table (excluding the corrupted columnstore index) before recreating the table and index from scratch to minimize data loss.

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

Troubleshooting Guide: Error 7992 – Cannot Shrink Read-Only Database

Why This Error Happens

This error occurs because SQL Server’s shrink operation (DBCC SHRINKDATABASE or the Shrink task in SSMS) requires write access to the database files in order to reorganize pages and release unused space back to the operating system. When a database is explicitly set to READ_ONLY mode, SQL Server blocks the shrink operation entirely since it cannot modify the file structure. This typically happens when an administrator intentionally set the database to read-only for archival purposes, or when a database was restored/attached in a read-only state and a maintenance plan or script subsequently attempted an automated shrink.

Step-by-Step Resolution Guide

Step 1: Verify the Current Database State

  • Open SQL Server Management Studio (SSMS) and connect to the instance running SQL Server 2025.
  • Run the following query to confirm the read-only status:
  SELECT name, state_desc, is_read_only 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • Confirm is_read_only returns 1 before proceeding.

Step 2: Switch the Database to Read-Write Mode

  • Ensure no active connections are using the database, as changing access mode requires exclusive access.
  • Execute the following T-SQL command to set the database to multi-user read-write mode:
  ALTER DATABASE [YourDatabaseName] SET READ_WRITE WITH ROLLBACK IMMEDIATE;
  • The WITH ROLLBACK IMMEDIATE clause forcibly disconnects any lingering sessions to apply the change instantly.

Step 3: Execute the Shrink Operation

  • Once the database reports is_read_only = 0, run the shrink command:
  DBCC SHRINKDATABASE (YourDatabaseName, 10);
  • Monitor the tempdb and transaction log usage during this process, as shrink operations on Windows Server 2025 can spike I/O temporarily on large data files.

Step 4: Revert to Read-Only (If Required)

  • If the read-only state was intentional (e.g., for a compliance archive), set it back after the shrink completes:
  ALTER DATABASE [YourDatabaseName] SET READ_ONLY WITH ROLLBACK IMMEDIATE;
  • Document this change in your maintenance logs to prevent future automated jobs from failing on this same error.

Alternative or Verification Steps

  • Verification: Re-run the sys.databases query from Step 1 to ensure is_read_only matches your desired end-state (0 or 1), and check the SQL Server Error Log to confirm Error 7992 no longer appears during subsequent maintenance windows.
  • Alternative: If you cannot take the database offline for a READ_WRITE switch due to high availability requirements, consider excluding this specific database from your shrink maintenance plan via the Maintenance Plan Wizard in SSMS by deselecting it under the “Databases” dropdown in the Shrink Database task.

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

Troubleshooting Guide: Error 7988 – Loop in Data Chain Detected

Why This Error Happens

Error 7988 occurs when DBCC CHECKTABLE or DBCC CHECKDB encounters a corrupted page chain in a system table, where a page’s forward or backward pointer incorrectly points back to a page already visited in the chain. This typically results from physical disk-level corruption, improper shutdowns, faulty storage controllers, or memory corruption that affected page allocation metadata before it was written to disk. Because the error is flagged as “unrepairable,” standard repair operations (including REPAIRALLOWDATA_LOSS) cannot resolve the issue on their own, often requiring manual intervention or restoration from backup.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS to get a full list of affected objects.
  • Note the Object ID and %S_PGID (page ID) referenced in the original Error 7988 message.
  • Check the SQL Server Error Log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log) for correlating I/O or storage warnings around the same timestamp.

Step 2: Isolate Hardware or Storage Issues

  • Open Windows Server 2025 Event Viewer and navigate to Windows Logs > System to check for Disk or ntfs warnings.
  • Run chkdsk D: /f /r (replace D: with your data drive) in an elevated Command Prompt to repair underlying file system errors.
  • If using virtualized storage, verify the integrity of the virtual disk (VHDX) via Hyper-V Manager or your SAN diagnostic tools.

Step 3: Restore from a Clean Backup

  • Since Error 7988 is explicitly unrepairable via DBCC, locate your most recent verified clean backup.
  • Use RESTORE DATABASE YourDatabaseName FROM DISK = 'E:\Backups\YourDB.bak' WITH REPLACE, RECOVERY to restore the database.
  • If point-in-time recovery is needed, apply subsequent transaction log backups using WITH NORECOVERY until the final log restore.

Step 4: Rebuild System Tables if No Backup Exists

  • If no viable backup is available, attempt to export data using the bcp utility or SSIS from unaffected tables to a new, healthy database.
  • Create a new database instance and manually migrate schemas and clean data from the corrupted instance.
  • Decommission the corrupted database once data migration is confirmed complete.

Alternative or Verification Steps

  • After restoration, immediately re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS to confirm the error no longer appears and the database returns a clean status.
  • If corruption recurs immediately after restore, run Windows Memory Diagnostic (mdsched.exe) and check physical RAM/storage controller firmware, as this points to active hardware failure rather than a one-time software glitch.

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

Troubleshooting Guide: SQL Server Error 7989

Why This Error Happens

Error 7989 is an informational message generated during a DBCC CHECKIDENT operation, reporting the current identity value of a table. While not technically a “failure” on its own, it often surfaces in administrator logs when identity values become inconsistent due to abrupt transaction rollbacks, improper shutdowns, or corrupted system metadata following an upgrade to SQL Server 2025. This typically indicates that the identity cache (a performance feature in modern SQL Server versions) is out of sync with the actual data stored in the table, or that underlying database pages have minor corruption affecting the metadata.

Step-by-Step Resolution Guide

Step 1: Verify the Current Identity Status

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run the following command to check the status without making changes:
  DBCC CHECKIDENT ('YourTableName', NORESEED);
  • Review the output message associated with Error 7989 to compare the “current identity value” against the “current column value.”

Step 2: Reseed the Identity Value (If Discrepancy Found)

  • If the values do not match, force a reseed to the correct maximum value found in the column.
  • Execute the following, replacing the placeholder with the actual last used value:
  DBCC CHECKIDENT ('YourTableName', RESEED, [new_reseed_value]);
  • Ensure no active transactions are writing to this table while the reseed command executes to avoid primary key violations.

Step 3: Check for Underlying Database Corruption

  • If the issue persists after reseeding, run a full integrity check to rule out page-level corruption affecting the identity metadata.
  • Navigate to the Command Prompt (Run as Administrator) or SSMS Query Window and execute:
  DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • If corruption is detected, restore the specific table or database from the last known good backup rather than using REPAIR_ALLOW_DATA_LOSS.

Step 4: Update SQL Server 2025 Cumulative Updates

  • Verify you are running the latest Cumulative Update (CU) for SQL Server 2025, as early releases on Windows Server 2025 may have specific bugs regarding identity caching.
  • Go to the Microsoft Update Catalog and download the latest patch for your specific build.
  • Apply the patch during a scheduled maintenance window and restart the SQL Server (MSSQLSERVER) service via the SQL Server Configuration Manager.

Alternative or Verification Steps

  • Verification: Insert a test row into the affected table and confirm the generated ID follows sequentially from the reseeded value without throwing a primary key violation.
  • Alternative: If the identity cache feature is causing repeated gaps (though not an error, it causes confusion), consider setting the database compatibility level to disable the Identity Cache for that specific table via trace flag 272 if sequential IDs without gaps are a strict business requirement.

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

Troubleshooting Guide: Error 7986 – Cross-Object Chain Linkage Corruption in SQL Server 2025

Why This Error Happens

Error 7986 occurs when DBCC CHECKDB’s system table pre-checks detect that a page’s linkage metadata points to an incorrect object or allocation unit, indicating physical corruption in the system catalog’s internal page chain structure. This is typically caused by underlying storage subsystem failures, improper shutdowns, faulty I/O drivers, or memory corruption that occurred before data was flushed to disk. Because the corruption affects system-level allocation metadata rather than user data, SQL Server considers this “unrepairable” through standard REPAIRALLOWDATA_LOSS routines, since fixing it risks further destabilizing the database’s core structural integrity.

Step-by-Step Resolution Guide

Step 1: Isolate the Database and Confirm the Scope of Corruption

  • Immediately set the affected database to single-user or restrict access mode to prevent further writes: ALTER DATABASE [YourDB] SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE;
  • Run a full DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS, DATA_PURITY; and save the complete output to a text file.
  • Note the specific Object ID, Page ID (%S_PGID), and Allocation Unit ID values reported in the error—these identify exactly which system table is impacted.

Step 2: Check Hardware and Windows Event Logs for Root Cause

  • Open Event Viewer on Windows Server 2025 / Windows 11 and inspect the System and Application logs under Windows Logs for Disk, NTFS, or Storport errors around the time corruption began.
  • Run chkdsk C: /f /r (replace with the actual volume hosting your .mdf/.ndf files) during a scheduled maintenance window to rule out underlying disk-level corruption.
  • Verify SAN/storage controller firmware and drivers are current, especially if running on Hyper-V or virtualized storage.

Step 3: Restore from a Known-Good Backup

  • Since Error 7986 is explicitly flagged as unrepairable via DBCC repair options, locate your most recent clean full backup along with subsequent differential/log backups.
  • Restore the database to a new location first using RESTORE DATABASE [YourDB_Test] FROM DISK = 'path\to\backup.bak' WITH NORECOVERY; then apply logs sequentially.
  • Run DBCC CHECKDB against the restored copy before promoting it to production to confirm the backup itself is clean.

Step 4: Rebuild Corrupted System Table Structures (If No Backup Is Viable)

  • If no valid backup exists, export all recoverable user data via bcp or SSIS packages into a freshly created database with an identical schema.
  • Use sp_help and schema comparison tools (like SQL Server Data Tools or Redgate SQL Compare) to validate the new database structure matches the original before cutover.
  • Decommission the corrupted database only after confirming full data integrity in the new instance.

Alternative or Verification Steps

  • After restoration, re-run DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm zero allocation or consistency errors are returned.
  • If corruption recurs shortly after restoration, treat it as a hardware-level issue—run extended SMART diagnostics on physical disks and consider migrating the database to a different storage volume or host entirely.

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

Troubleshooting Guide: Error 7987 – System Table Pre-Checks Chain Linkage Mismatch

Why This Error Happens

Error 7987 occurs when DBCC CHECKDB’s system table pre-check phase detects that the page linkage (next/previous pointers) within a system table’s page chain is broken or inconsistent. This typically results from physical corruption caused by faulty storage hardware, improper shutdowns, or interrupted I/O operations that left page allocation metadata out of sync. It can also surface after a failed in-place upgrade or an abrupt crash during a system catalog update, leaving the %S_PGID->next pointer referencing a page ID that doesn’t correctly link back to the expected object chain.

Step-by-Step Resolution Guide

Step 1: Isolate the Affected Database and Stop Further Writes

  • Immediately set the database to SINGLE_USER mode to prevent additional transactions from compounding the corruption: ALTER DATABASE [YourDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Avoid running any write operations (INSERT/UPDATE/DELETE) against the database until diagnostics are complete.
  • Check the SQL Server error log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for correlating I/O or storage-related warnings (e.g., Event ID 823 or 824).

Step 2: Run a Full DBCC CHECKDB Diagnostic

  • Execute DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS, DATA_PURITY; to get a complete picture of corruption scope beyond just the system table.
  • Note the Object ID referenced in the error (the %d value) and cross-reference it using SELECT OBJECT_NAME(object_id) FROM sys.objects WHERE object_id = <ObjectID>; if it’s a user table; system table IDs (negative values) indicate catalog-level corruption.
  • If the corruption is isolated to a single page, document the %S_PGID values (file:page format) for targeted repair.

Step 3: Restore from a Clean Backup (Preferred Method)

  • Locate the most recent full backup taken before corruption was introduced, ideally verified with RESTORE VERIFYONLY.
  • Restore to a new database name first to confirm integrity: RESTORE DATABASE [YourDB_Test] FROM DISK = 'D:\Backups\YourDB.bak' WITH MOVE, REPLACE;
  • Run DBCC CHECKDB against the restored copy before promoting it to production to ensure the chain linkage error does not persist.

Step 4: Use Repair Options Only as a Last Resort

  • If no clean backup exists, run DBCC CHECKDB ('YourDB', REPAIR_ALLOW_DATA_LOSS) while in SINGLE_USER mode, understanding this may delete corrupted rows/pages to resolve linkage.
  • Take a full backup immediately after repair completes, since repaired databases should not be considered fully trustworthy long-term.
  • Review sys.dm_db_page_info (new in SQL Server 2025) on the affected pages post-repair to confirm linkage integrity.

Step 5: Check Underlying Storage Health

  • On Windows Server 2025 / Windows 11, run chkdsk D: /f /r (replace D: with your data drive) during a maintenance window to rule out disk-level corruption.
  • Review Windows Event Viewer under Windows Logs > System for Disk or NTFS warning events (Event ID 7, 11, 51) that may indicate failing storage hardware.
  • If using virtualized storage or SAN, validate with your storage vendor’s diagnostic tools for latency or write-cache failures.

Alternative or Verification Steps

  • After remediation, re-run DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm it returns zero allocation or consistency errors before returning the database to MULTI_USER mode.
  • If Error 7987 recurs shortly after repair, treat it as a hardware reliability issue rather than a SQL Server logical problem — engage your storage/hardware team and consider migrating the database to new storage via backup/restore.

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

Troubleshooting Guide: Error 7984 – Unexpected Page Type During System Table Pre-Checks

Why This Error Happens

Error 7984 occurs when DBCC CHECKDB encounters a system table page whose header type does not match what SQL Server’s storage engine expects, indicating physical-level corruption in the database’s metadata structures. This is typically caused by underlying disk I/O failures, improper shutdowns, faulty storage controllers, or corrupted memory pages being flushed to disk before the system catalog pages were fully written. Because system tables are foundational to database operations, SQL Server treats this as an unrepairable error and immediately terminates the CHECKDB operation rather than risk further damage.

Step-by-Step Resolution Guide

Step 1: Isolate the Database and Stop Further Writes

  • Set the affected database to SINGLEUSER or READONLY mode to prevent additional transactions from compounding the corruption.
  • Run: ALTER DATABASE [YourDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Avoid running any further DML operations until the root cause is identified.

Step 2: Check Hardware and Storage Subsystem Health

  • Review the Windows Event Viewer (Application and System logs) on Windows Server 2025 for disk-related warnings (Event ID 51, 129, or 153).
  • Run chkdsk C: /f /r (adjust drive letter to the SQL data volume) to scan for file system or sector-level errors.
  • If using virtualized storage (Hyper-V/VMware), validate the underlying SAN/NAS or vDisk for pending hardware faults.

Step 3: Restore from a Known-Good Backup

  • Since Error 7984 is flagged as “unrepairable,” the most reliable fix is restoring from your last verified clean backup.
  • Use SQL Server Management Studio (SSMS) or T-SQL: RESTORE DATABASE [YourDB] FROM DISK = 'E:\Backups\YourDB_Full.bak' WITH REPLACE, RECOVERY;
  • If point-in-time recovery is needed, apply subsequent transaction log backups after the full restore.

Step 4: Rebuild System Tables (Only if No Backup Exists)

  • As a last resort, attempt to extract salvageable data using DBCC CHECKDB WITH TABLERESULTS to generate a damage report.
  • Export any accessible user data via SELECT INTO statements to a new, healthy database before rebuilding.
  • If system catalog corruption is severe, a full SQL Server instance rebuild (setup.exe /ACTION=REBUILDDATABASE) may be required to reset master/model/msdb, followed by re-attaching user databases.

Alternative or Verification Steps

  • After restoring, run DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS; to confirm Error 7984 no longer appears and the database reports zero allocation or consistency errors.
  • If corruption recurs after restoration, treat it as a hardware-level issue and run extended diagnostics (manufacturer disk utility or Test-Disk PowerShell cmdlets) on the physical storage array before returning the database to production.

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

Troubleshooting Guide: SQL Server Error 7985 — “Could Not Read and Latch Page During System Table Pre-Checks”

Why This Error Happens

Error 7985 occurs during DBCC CHECKDB system table pre-checks when the database engine cannot acquire a latch on a specific page, typically because the underlying data file has corrupted or inaccessible pages at the storage level. This is most often caused by disk I/O failures, an unexpected shutdown that left the database in an inconsistent state, or underlying storage hardware/driver issues on Windows Server 2025 that silently corrupted pages before SQL Server 2025 could flush them correctly. Since this check targets critical system tables, the error is flagged as unrepairable because standard repair options (REPAIRALLOWDATA_LOSS) cannot safely reconstruct core metadata structures.

Step-by-Step Resolution Guide

Step 1: Verify the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to confirm whether the corruption is isolated to the reported Object ID or spans multiple objects.
  • Check the SQL Server error log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for any preceding 823, 824, or 825 errors indicating a hardware-level I/O problem.
  • Cross-reference Windows Event Viewer under Windows Logs > System for Disk or NTFS warnings around the same timestamp.

Step 2: Restore From a Known-Good Backup

  • Since system table page corruption is generally unrepairable in place, identify your most recent clean full backup using RESTORE HEADERONLY FROM DISK = 'D:\Backups\YourDatabase.bak';.
  • Perform a full restore sequence (Full + Differential + Transaction Logs) to a point before the corruption occurred:
    RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDatabase.bak' WITH NORECOVERY;
  • Apply subsequent log backups with WITH RECOVERY on the final one to bring the database online.

Step 3: Validate Underlying Storage Health

  • Open PowerShell as Administrator and run Get-PhysicalDisk | Get-StorageReliabilityCounter to check for read/write error counts on the volume hosting your .mdf/.ldf files.
  • Run chkdsk D: /f /r (replace D: with your data drive) during a maintenance window to repair file system-level errors.
  • If using virtualized storage (Hyper-V/VMware on Windows Server 2025), verify the virtual disk isn’t thin-provisioned on a nearly-full datastore, which can trigger silent write failures.

Step 4: Rebuild the Database If No Backup Exists

  • As a last resort, if no valid backup is available, use sp_detach_db followed by sp_attach_db to attempt re-registration of the files, though this rarely resolves system table corruption.
  • If the database still won’t mount, create a new database and use the Import/Export Wizard or bcp to extract any salvageable user data from readable tables before decommissioning the corrupted database.

Alternative or Verification Steps

  • After restoring, immediately re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS; and confirm it returns zero allocation or consistency errors.
  • If error 7985 persists only on this one Object ID after restore, open a Microsoft Support case referencing Error 7985 — this specific error on system catalog views in SQL Server 2025 may indicate a storage driver incompatibility requiring a vendor patch.

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

Troubleshooting Guide: SQL Server Error 7982 — “Oldest Non-Distributed LSN”

Why This Error Happens

This error occurs when SQL Server’s transaction log reader (Log Reader Agent) for replication cannot advance the log truncation point because older transactions remain undistributed to subscribers. This typically happens when replication is lagging, the Distribution Agent is stalled or disabled, or the distribution database has grown excessively and cannot process the backlog in time. Underlying causes often include network connectivity issues between Publisher/Distributor/Subscriber, insufficient disk I/O throughput, or a Subscriber that has been offline for an extended period, causing the log to hold LSNs indefinitely.

Step-by-Step Resolution Guide

Step 1: Verify Replication Agent Status

  • Open SQL Server Management Studio (SSMS) and connect to the Distributor instance.
  • Navigate to Replication > Monitor and check the status of the Log Reader Agent and Distribution Agent.
  • Run the following query against the distribution database to confirm the oldest undistributed LSN:
  EXEC sp_replmonitorhelppublication;
  • Look for agents showing “Retrying” or “Failed” status, as these are blocking log truncation.

Step 2: Clear the Replication Backlog

  • If a Subscriber is offline or unreachable, identify it using:
  EXEC sp_helpsubscription;
  • Restart the stalled Distribution Agent manually via SQL Server Agent Jobs in SSMS (SQL Server Agent > Jobs).
  • If the Subscriber is permanently unavailable, consider dropping the subscription to release the LSN lock:
  EXEC sp_dropsubscription @publication = 'YourPublicationName', @subscriber = 'SubscriberName';

Step 3: Check Disk Space and Log File Growth

  • Confirm the transaction log drive (commonly D:\SQLData\Logs\) has sufficient free space, as a full log can prevent LSN advancement.
  • Use DBCC SQLPERF(LOGSPACE); to check log space usage across all databases.
  • If the log is near capacity, perform a manual log backup (if in Full Recovery Model):
  BACKUP LOG [YourDatabase] TO DISK = 'E:\Backups\YourDatabase_Log.trn';

Step 4: Validate Distribution Database Retention Settings

  • Open Replication > Distributor Properties in SSMS.
  • Check the Transaction retention and History retention settings (default is 72 hours); reduce retention if the backlog is due to excessive hold time.
  • Apply changes and restart the Log Reader Agent job to force re-evaluation of the retention window.

Alternative or Verification Steps

  • After applying fixes, re-run EXEC sp_replmonitorhelppublication; and confirm the “Oldest Distributed Transaction” timestamp is advancing in near real-time.
  • If the issue persists, use Performance Monitor (PerfMon) with the SQLServer:Replication Agents counter to confirm agents are actively processing commands rather than idling or erroring out.

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

Troubleshooting Guide: Error 7983 – DBCC Permission Denied in SQL Server 2025

Why This Error Happens

Error 7983 occurs when a SQL Server login attempts to execute a DBCC command without holding the required permissions, typically because the user lacks the necessary server or database role membership. This is commonly seen when standard users (not sysadmins or db_owners) attempt to run maintenance commands like DBCC CHECKDB, DBCC SHRINKDATABASE, or DBCC FREEPROCCACHE, which require elevated privileges. In SQL Server 2025, this restriction is enforced more strictly due to updated security baselines in Windows Server 2025 environments, which tightly integrate with Azure AD/Entra ID authentication policies.

Step-by-Step Resolution Guide

Step 1: Verify the Current User’s Role Membership

  • Open SQL Server Management Studio (SSMS) and connect using an account with sysadmin privileges.
  • Run the following query to check the user’s current roles: SELECT IS_ROLEMEMBER('sysadmin')
  • Identify whether the user belongs to db_owner (for database-scoped DBCC commands) or sysadmin (for server-scoped DBCC commands like DBCC FREESYSTEMCACHE).

Step 2: Grant the Appropriate Role or Permission

  • For database-level DBCC commands (e.g., DBCC CHECKDB), add the user to the db_owner role: ALTER ROLE db_owner ADD MEMBER [DOMAIN\Username];
  • For server-level DBCC commands, add the user to the sysadmin fixed server role: ALTER SERVER ROLE sysadmin ADD MEMBER [DOMAIN\Username];
  • If using granular permissions instead of fixed roles, grant specific permissions like ALTER ANY DATABASE or VIEW SERVER STATE depending on the DBCC command being used.

Step 3: Check Group Policy and Windows Authentication Settings

  • On Windows Server 2025, navigate to Local Security Policy > Security Settings > Local Policies > User Rights Assignment.
  • Ensure the SQL Server service account has not been restricted from “Log on as a service” or similar rights that might cascade into permission failures.
  • Verify Active Directory group policies are not overriding SQL Server login mappings by checking Group Policy Management Console (GPMC) for conflicting domain-level SQL Server security templates.

Step 4: Restart SQL Server Service and Clear Cached Credentials

  • Open SQL Server Configuration Manager, locate the SQL Server (MSSQLSERVER) service, and restart it to apply new role memberships.
  • Clear any cached login tokens by running: DBCC FREESYSTEMCACHE('ALL'); (only if you already have temporary sysadmin access).
  • Confirm the user logs out and reconnects in SSMS to refresh their session permissions.

Alternative or Verification Steps

  • Verify the fix by having the affected user re-run the original DBCC command; it should execute without the Error 7983 message appearing in the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • If role assignment does not resolve the issue, check for Azure Arc-enabled server policies on Windows Server 2025 that may be overriding local SQL permissions, and temporarily disable them to isolate the root cause.

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

Why This Error Happens

Error 7980 is raised when SQL Server cannot truncate the transaction log because a Distributed Availability Group replica (typically the forwarder in the secondary AG) has not yet hardened the log past the reported LSN. This is usually caused by network latency or a broken link between the primary AG and the secondary AG’s forwarder, a secondary replica that is offline or unreachable, or a replica that is stuck in a “NOT SYNCHRONIZING” state. Because the distributed AG tracks log consumption separately from local availability group replicas, a lagging remote forwarder will cause log growth and repeated 7980 messages even if all local replicas are healthy.

Step-by-Step Resolution Guide

Step 1: Identify the Lagging Replica

  • Run the following query on the primary replica to find which secondary (local or distributed) is behind:
    SELECT ag.name, ar.replica_server_name, drs.last_hardened_lsn, drs.last_received_lsn FROM sys.dm_hadr_database_replica_states drs JOIN sys.availability_replicas ar ON drs.replica_id = ar.replica_id JOIN sys.availability_groups ag ON ar.group_id = ag.group_id;
  • Pay close attention to the last_hardened_lsn on the forwarder instance of the secondary distributed availability group — this is the most common bottleneck.

Step 2: Check Network and Endpoint Health Between Distributed AG Instances

  • From the primary AG’s primary replica, test connectivity to the forwarder’s mirroring endpoint:
    Test-NetConnection -ComputerName <ForwarderServerName> -Port 5022
  • Confirm the endpoint state is STARTED on both instances:
    SELECT name, state_desc FROM sys.database_mirroring_endpoints;
  • If packets are dropping or latency is high (common in cross-region Windows Server 2025 deployments), work with your network team to resolve routing, firewall, or VPN tunnel issues before proceeding.

Step 3: Resynchronize or Restart the Distributed AG Forwarder

  • On the forwarder instance, restart the SQL Server service to force a renegotiation of the distributed AG session:
    Restart-Service -Name 'MSSQLSERVER' -Force
  • If the forwarder remains stalled, remove and re-add the secondary availability group to the distributed AG using:
    ALTER AVAILABILITY GROUP [DistributedAG_Name] MODIFY AVAILABILITY GROUP ON 'SecondaryAG_Name' WITH (AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT);

Step 4: Manage Transaction Log Growth While Waiting

  • If the log drive is nearing capacity before the lag clears, temporarily add a secondary log file on a different volume:
    ALTER DATABASE [YourDB] ADD LOG FILE (NAME = TempLog02, FILENAME = 'E:\SQLLogs\TempLog02.ldf', SIZE = 5GB);
  • Avoid shrinking or manually truncating the log — doing so can break log chain continuity for the distributed AG and force a full reseed.

Alternative or Verification Steps

  • Re-run the DMV query from Step 1 and confirm last_hardened_lsn on the forwarder now matches (or is very close to) the primary’s current LSN, and check that the 7980 messages stop appearing in the SQL Server error log.
  • If the forwarder cannot catch up after retrying, consider temporarily removing the secondary AG from the distributed AG topology and re-adding it with a fresh seeding operation (ALTER AVAILABILITY GROUP ... JOIN AVAILABILITY GROUP) to reset the LSN tracking state.

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

Troubleshooting Guide: SQL Server Error 7981 – Clustered Columnstore Index Corruption

Why This Error Happens

Error 7981 occurs when SQL Server’s DBCC CHECKDB operation detects structural inconsistencies within a clustered columnstore index, typically caused by corrupted compressed row groups or mismatched metadata between the delta store and the columnstore segments. This commonly results from unexpected shutdowns, storage subsystem failures, or bad sectors on disk that corrupt the underlying data pages during write operations. In some cases, this also surfaces after improper restores, antivirus interference with database files, or bugs triggered by outdated SQL Server 2025 cumulative updates.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to identify all affected objects.
  • Note the exact table name, index name, and row group IDs referenced in the Error 7981 output.
  • Check the SQL Server Error Log (default path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related I/O warnings.

Step 2: Check Underlying Storage Health

  • Open Event Viewer on Windows Server 2025/Windows 11 and inspect the System log for Disk or NTFS warnings (Event ID 7, 51, or 153).
  • Run chkdsk C: /f /r (replace C: with your data drive) during a maintenance window to repair file system-level errors.
  • Validate that antivirus real-time scanning excludes .mdf, .ndf, and .ldf files via Windows Security > Virus & Threat Protection > Exclusions.

Step 3: Rebuild or Drop/Recreate the Columnstore Index

  • Attempt a rebuild first: ALTER INDEX [YourColumnstoreIndexName] ON [YourTableName] REBUILD;
  • If the rebuild fails, drop and recreate the index: DROP INDEX [YourColumnstoreIndexName] ON [YourTableName]; followed by CREATE CLUSTERED COLUMNSTORE INDEX [YourColumnstoreIndexName] ON [YourTableName];
  • Ensure sufficient tempdb space is available, as columnstore rebuilds are I/O and memory intensive.

Step 4: Restore from Backup if Rebuild Fails

  • If corruption persists, restore the affected database from the last known good backup using RESTORE DATABASE [YourDatabaseName] FROM DISK = 'E:\Backups\YourBackup.bak' WITH REPLACE;
  • Apply transaction log backups afterward to minimize data loss.
  • As a last resort, run DBCC CHECKDB ('YourDatabaseName') WITH REPAIR_ALLOW_DATA_LOSS; only in an isolated test environment first, since this may delete corrupted rows permanently.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; after remediation to confirm zero allocation and consistency errors are reported.
  • If corruption recurs frequently, check for firmware/driver updates on the storage controller and confirm SQL Server 2025 is patched to the latest Cumulative Update (CU) via Microsoft Update Catalog.

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

Troubleshooting Guide: SQL Server Error 7978 (SID Mismatch)

Why This Error Happens

Error 7978 occurs when SQL Server 2025 encounters a Security Identifier (SID) mismatch during authentication, replication, or Availability Group operations, typically because a login’s SID stored in the master database does not match the SID stored in the user database or on the Windows domain controller. This commonly happens after restoring a database from a different server, migrating logins between environments, or when a Windows account is recreated with the same name but a new underlying SID. Corrupted entries in sys.server_principals or orphaned users left behind after a database restore can also trigger this inconsistency.

Step-by-Step Resolution Guide

Step 1: Identify the Mismatched SID

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run the following query to compare server-level and database-level SIDs:
SELECT name, sid FROM sys.server_principals WHERE name = 'DOMAIN\UserName';
SELECT name, sid FROM sys.database_principals WHERE name = 'DOMAIN\UserName';
  • Note the exact SID value reported in the error message text (SID : %.*ls) from the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.

Step 2: Resolve Orphaned Users

  • If the database SID does not match the server SID, run sp_change_users_login (legacy instances) or the modern equivalent:
ALTER USER [DOMAIN\UserName] WITH LOGIN = [DOMAIN\UserName];
  • This remaps the database user to the correct server-level login SID without requiring a drop/recreate cycle.

Step 3: Drop and Recreate the Login (If Windows SID Changed)

  • If the Windows account itself was deleted and recreated (common in Active Directory resets), the underlying SID is permanently different and cannot be remapped.
  • Drop the stale login:
DROP LOGIN [DOMAIN\UserName];
  • Recreate it fresh so SQL Server pulls the current AD SID:
CREATE LOGIN [DOMAIN\UserName] FROM WINDOWS;
  • Re-run Step 2 to re-link the database user to this new login.

Step 4: Validate Active Directory Connectivity

  • On Windows Server 2025, confirm the SQL Server service account can reach the domain controller via nltest /sc_query:DOMAINNAME.
  • Ensure Kerberos/NTLM authentication isn’t being blocked by a firewall rule or Group Policy change introduced after a recent Windows Server 2025 update.

Alternative or Verification Steps

  • Verify the fix by re-running the sys.server_principals vs sys.database_principals SID comparison query from Step 1 — the values should now match exactly.
  • If the error persists during Availability Group synchronization, check that the same login/SID exists identically on all replica nodes, as AG failover will reproduce Error 7978 if logins aren’t synchronized cluster-wide.

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

Troubleshooting Guide: SQL Server Error 7979

Why This Error Happens

Error 7979 typically occurs during transactional replication when the replication agent encounters an inconsistency while processing replicated transaction metadata, often due to a corrupted distribution database or a mismatch between the publisher and subscriber schema versions. This can also result from interrupted log reader agent jobs, orphaned replication metadata left behind after an improper cleanup, or insufficient permissions on the distribution database for the account running the replication agents. In some cases, the issue stems from a corrupted .cache file used by the Log Reader Agent on Windows Server 2025 environments with aggressive disk cleanup policies.

Step-by-Step Resolution Guide

Step 1: Verify Replication Agent Status and Logs

  • Open SQL Server Management Studio (SSMS) and connect to the Distributor instance.
  • Navigate to Replication > Monitor and check the status of the Log Reader Agent and Distribution Agent.
  • Review the agent history for the exact failing transaction sequence number (xact_seqno) referenced alongside Error 7979.
  • Check the SQL Server error log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for additional context.

Step 2: Validate and Repair Distribution Database Integrity

  • Run DBCC CHECKDB (distribution) WITH NO_INFOMSGS, ALL_ERRORMSGS; to check for corruption in the distribution database.
  • If corruption is found, restore the distribution database from the last known good backup rather than attempting an in-place repair.
  • Execute sp_browsereplcmds on the publisher to confirm whether the problematic transaction can be read without errors.

Step 3: Reinitialize the Affected Subscription

  • In SSMS, right-click the problematic subscription under Local Subscriptions and select Reinitialize Subscription.
  • Alternatively, run the following T-SQL on the publisher:
  • EXEC sp_reinitsubscription @subscriber = N'SubscriberName', @destination_db = N'DestinationDB', @publication = N'PublicationName';
  • Restart the SQL Server Agent service via services.msc on both the Distributor and Subscriber servers to clear any cached job states.

Step 4: Check Permissions on Replication Agent Accounts

  • Confirm the account running the SQL Server Agent service has db_owner rights on the distribution database.
  • Validate this using EXEC sp_helprotect NULL, NULL, 'distribution';
  • Ensure the account also has Log on as a service rights in Local Security Policy (secpol.msc) on Windows Server 2025.

Alternative or Verification Steps

  • After reinitializing, monitor the Replication Monitor for at least one full synchronization cycle to confirm Error 7979 does not reoccur.
  • If the error persists, drop and recreate the publication entirely using sp_droppublication and sp_addpublication, then re-add subscribers to eliminate any residual metadata corruption.

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

Troubleshooting Guide: Error 7976 – Missing Column Segment in Nonclustered Columnstore Index

Why This Error Happens

Error 7976 occurs when SQL Server detects that a rowgroup in a nonclustered columnstore index is missing an expected column segment, indicating that the underlying index metadata is corrupted or incomplete. This typically results from storage-level corruption (bad disk sectors, improper shutdowns, or SAN/storage replication issues), an interrupted index build or rebuild operation, or hardware-level I/O errors that silently damaged the column store object (CSO) pages before they were flushed to disk. Because columnstore indexes store data in a highly compressed, segment-based format, a single missing segment breaks the internal consistency checks SQL Server relies on to reconstruct query results.

Step-by-Step Resolution Guide

Step 1: Confirm and Scope the Corruption

  • Run DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS, ALL_ERRORMSGS; to confirm Error 7976 is isolated to the columnstore index and not indicative of broader database corruption.
  • Note the exact table name, index name, column id, and rowgroup id reported in the error message for precise targeting.
  • Check the SQL Server Error Log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for correlating I/O or storage warnings around the same timestamp.

Step 2: Drop and Recreate the Nonclustered Columnstore Index

  • Identify the exact index definition first by running sp_helpindex 'YourTableName'; or querying sys.indexes and sys.index_columns to capture included columns and filters.
  • Drop the corrupted index: DROP INDEX [YourColumnstoreIndexName] ON [dbo].[YourTableName];
  • Recreate it using the captured definition: CREATE NONCLUSTERED COLUMNSTORE INDEX [YourColumnstoreIndexName] ON [dbo].[YourTableName] ([Col1], [Col2], [Col3]);
  • For very large tables, consider adding WITH (DROP_EXISTING = ON, MAXDOP = 4) syntax where applicable to manage server load during rebuild.

Step 3: Investigate Underlying Storage/Hardware Causes

  • Check Windows Event Viewer (Event Viewer → Windows Logs → System) for Disk, NTFS, or Storport errors that coincide with the SQL Server error timestamp.
  • Run chkdsk D:\ /f /r (replace with the actual data drive letter) during a maintenance window to repair file system-level issues.
  • Verify virtual disk health if running on Hyper-V or a SAN-backed volume, and confirm no recent unexpected restarts or storage failovers occurred.

Step 4: Review Backup and Maintenance Strategy

  • Ensure a full database backup was taken immediately before the drop/recreate operation, in case rollback is needed: BACKUP DATABASE YourDatabaseName TO DISK = 'D:\Backups\YourDatabaseName_PreFix.bak';
  • Schedule or verify DBCC CHECKDB runs regularly (weekly recommended) via SQL Server Agent to catch index corruption early going forward.

Alternative or Verification Steps

  • After recreating the index, re-run DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm no further Error 7976 or related columnstore errors appear.
  • If corruption recurs shortly after rebuild, treat it as a hardware/storage reliability issue — run full memory diagnostics (mdsched.exe) and storage controller firmware checks, since repeated columnstore corruption often points to a failing disk subsystem rather than a SQL Server defect.

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

Why This Error Happens

Error 7977 occurs when SQL Server attempts to write a backup or restore operation’s metadata into the msdb history tables (such as backupset, backupmediafamily, or restorehistory) and fails to do so. This typically happens because of insufficient permissions on the msdb database, corruption or schema mismatch in the history tables following an incomplete upgrade, or because the msdb database itself is in a restricted state (read-only, single-user, or suspect). The placeholder text “Start time : %.*ls” is part of the unformatted error message template that SQL Server failed to populate correctly because the underlying INSERT into the history table was rejected.

Step-by-Step Resolution Guide

Step 1: Verify Permissions on the msdb Database

  • Confirm the SQL Server service account and the login executing the backup/restore are members of the db_backupoperator role or sysadmin fixed server role.
  • Run the following to check current role membership:
USE msdb;
EXEC sp_helprolemember 'db_backupoperator';
  • Grant the role if missing:
USE msdb;
ALTER ROLE db_backupoperator ADD MEMBER [YourLoginName];

Step 2: Check the Health and State of msdb

  • Ensure msdb is not in READ_ONLY, SINGLE_USER, or SUSPECT mode.
  • Run:
SELECT name, state_desc, user_access_desc 
FROM sys.databases 
WHERE name = 'msdb';
  • If the state is anything other than ONLINE / MULTI_USER, bring it back online:
ALTER DATABASE msdb SET ONLINE;
ALTER DATABASE msdb SET MULTI_USER;

Step 3: Validate and Repair History Tables

  • Check for corruption or schema drift in the backup/restore history tables, which is common after an in-place upgrade to SQL Server 2025.
  • Run a consistency check scoped to msdb:
DBCC CHECKDB (msdb) WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • If corruption is found in backupset, backupmediafamily, or restorehistory, restore msdb from a known-good backup or rebuild the system databases using the SQL Server 2025 setup media (Setup.exe /ACTION=REBUILDDATABASE).

Step 4: Re-run the Upgrade Scripts for msdb

  • If the issue surfaced immediately after a Cumulative Update or major version upgrade, manually re-apply the instmsdb.sql schema update script located in:
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Install\
  • Execute it via SQLCMD in single-user maintenance mode:
sqlcmd -S localhost -E -i instmsdb.sql

Step 5: Confirm Disk Space and File Growth Settings

  • Insufficient space in the msdb data or log files can also cause this insert failure.
  • Check free space on the volume hosting msdb.mdf / msdblog.ldf and ensure autogrowth is enabled:
EXEC sp_helpdb 'msdb';

Alternative or Verification Steps

  • After applying fixes, run a manual test backup (BACKUP DATABASE TestDB TO DISK = 'NUL') and confirm no Error 7977 appears, then verify the entry exists via SELECT * FROM msdb.dbo.backupset ORDER BY backup_start_date DESC;.
  • If the error persists, as a fallback, rebuild system databases entirely using Setup.exe /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=BUILTIN\Administrators and restore msdb from your most recent valid backup.

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

Troubleshooting Guide: Error 7974 – Microsoft SQL Server 2025

Why This Error Happens

Error 7974 typically occurs when SQL Server encounters a resource or metadata inconsistency tied to a specific named object (as indicated by the Name : %.*ls placeholder), often a filegroup, index, or Full-Text Catalog component. This is commonly triggered by corrupted system catalog entries, mismatched schema references after an in-place upgrade to SQL Server 2025, or insufficient permissions on the Windows Server 2025 / Windows 11 file system where the resource resides. In some cases, this error surfaces when the Database Engine service account lacks the necessary NTFS permissions to access the underlying data or log files referenced by the named object.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Object Referenced in the Error

  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) to find the full resolved name replacing %.*ls.
  • Run the following query to cross-reference the object against system catalogs:
SELECT * FROM sys.objects WHERE name = 'ObjectNameFromLog';
  • Note whether the object is a table, index, filegroup, or Full-Text component, as this determines the next steps.

Step 2: Verify File System Permissions and Integrity

  • Navigate to the data/log file directory, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.
  • Right-click the relevant .mdf, .ndf, or .ldf file, go to Properties > Security, and confirm that the SQL Server service account (e.g., NT Service\MSSQLSERVER) has Full Control.
  • Run CHKDSK C: /F /R from an elevated PowerShell prompt on Windows Server 2025 to rule out underlying disk corruption.

Step 3: Run Database Consistency Checks

  • Open SQL Server Management Studio (SSMS) and execute:
DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • If corruption is confirmed on the named object, attempt a targeted repair:
DBCC CHECKDB('YourDatabaseName', REPAIR_REBUILD);
  • Avoid REPAIR_ALLOW_DATA_LOSS unless a verified backup exists, as this option may discard data silently.

Step 4: Rebuild or Restore the Affected Object

  • If the object is an index, rebuild it explicitly:
ALTER INDEX ALL ON dbo.YourTableName REBUILD;
  • If the object is a Full-Text Catalog, drop and recreate it using DROP FULLTEXT CATALOG followed by CREATE FULLTEXT CATALOG.
  • If corruption persists, restore the database from the last known good backup using SSMS’s Restore Database wizard.

Alternative or Verification Steps

  • After applying fixes, restart the SQL Server 2025 service via services.msc or Restart-Service MSSQLSERVER in PowerShell, then re-run DBCC CHECKDB to confirm zero errors are returned.
  • If the error recurs immediately, apply the latest SQL Server 2025 Cumulative Update (CU) from the Microsoft Update Catalog, as unresolved platform-level bugs on Windows Server 2025 may require a patched build.

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

Troubleshooting Guide: SQL Server Error 7975

Why This Error Happens

Error 7975 is typically raised during transactional replication or Change Data Capture (CDC) log scan operations when the Log Sequence Number (LSN) referenced in the transaction log cannot be located or read correctly. This usually occurs because the transaction log has been truncated, corrupted, or modified outside of SQL Server’s control (such as through improper backup restoration or disk-level corruption) before the Log Reader Agent or CDC scan process could process the required records. In some cases, this also surfaces when log backups are missing from the restore chain, breaking the continuity of LSNs that replication or CDC depends on.

Step-by-Step Resolution Guide

Step 1: Verify the Integrity of the Transaction Log

  • Run DBCC CHECKDB WITH NO_INFOMSGS, ALL_ERRORMSGS against the affected database to rule out physical corruption.
  • Check the SQL Server Error Log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related I/O or corruption warnings preceding Error 7975.
  • Confirm disk health using Windows Server 2025 Storage Spaces diagnostics or chkdsk if the database resides on a local volume.

Step 2: Reinitialize Replication or CDC if LSN Chain is Broken

  • If the error originates from the Log Reader Agent, open Replication Monitor and check the publication status.
  • Execute sp_replrestart on the publisher database to attempt to realign the Log Reader Agent with the current LSN.
  • If CDC is involved, run sys.sp_cdc_disable_db followed by sys.sp_cdc_enable_db to reset the capture instance (note: this requires reinitializing any downstream consumers).

Step 3: Rebuild the Log Reader Agent Metadata

  • Stop the Log Reader Agent via SQL Server Agent in SSMS.
  • Drop and recreate the Log Reader Agent job using sp_dropdistributiondb and corresponding setup scripts if metadata is irrecoverably desynchronized.
  • Restart the SQL Server service via services.msc on Windows Server 2025 to clear any cached LSN pointers held in memory.

Step 4: Validate the Backup and Restore Chain

  • Ensure no log backups were skipped or deleted between the last full backup and the point of failure.
  • Use RESTORE HEADERONLY against your .trn files to confirm LSN continuity (FirstLSN/LastLSN must match sequentially).
  • Re-run a full backup and fresh log backup chain if gaps are detected, then reconfigure replication against the new baseline.

Alternative or Verification Steps

  • Confirm resolution by querying sys.dm_repl_traninfo or cdc.lsn_time_mapping to verify that LSN values are now being generated and consumed without gaps.
  • If the issue persists after agent resets, consider dropping and fully reconfiguring the publication/subscription (or CDC instance) from scratch, as a corrupted distribution database may require a complete rebuild via sp_replicationdboption disable/enable cycle.

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

Why This Error Happens

Error 7972 occurs when the SQL Server Security Catalog encounters a mismatched or orphaned entry between a database principal’s UID (User ID) and its corresponding Security Identifier (SID) in master.sys.server_principals. This typically happens after a database restore/migration from an older instance, a failed Always Encrypted enclave attestation, or corruption in the internal metadata tables that map logins to database users. In SQL Server 2025, this is also frequently triggered by a broken link between a contained user and the Entra ID (Azure AD) authentication cache on Windows Server 2025 hosts.

Step-by-Step Resolution Guide

Step 1: Identify the Orphaned UID

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run the following query to locate the orphaned UID reported in the error:
SELECT dp.name, dp.sid, dp.type_desc 
FROM sys.database_principals dp
LEFT JOIN sys.server_principals sp ON dp.sid = sp.sid
WHERE sp.sid IS NULL AND dp.type IN ('S','U');
  • Cross-reference the numeric UID from the error message with the principal_id column to confirm the exact user causing the fault.

Step 2: Repair the Security Mapping

  • Use sp_change_users_login (legacy) or the 2025-native ALTER USER syntax to re-link the orphaned UID to a valid login:
ALTER USER [YourUserName] WITH LOGIN = [YourServerLogin];
  • If the login no longer exists on the server, recreate it first via CREATE LOGIN [YourServerLogin] WITH PASSWORD = '...'; before re-mapping.

Step 3: Rebuild the Security Catalog Cache

  • Stop the SQL Server service via services.msc or PowerShell:
Stop-Service -Name 'MSSQLSERVER' -Force
  • Clear the stale security cache located at:
    C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Security\SecurityCache.dat
  • Restart the service:
Start-Service -Name 'MSSQLSERVER'

Step 4: Validate Windows Authentication Integration

  • On Windows Server 2025/Windows 11, open secpol.msc and confirm the SQL Server service account still has “Log on as a service” rights.
  • If using Entra ID hybrid authentication, run Test-SqlEntraIdConnection (new 2025 cmdlet) to confirm the token cache is synchronized.

Alternative or Verification Steps

  • Verify the fix by re-running the query in Step 1 — it should return zero rows, confirming no orphaned UIDs remain.
  • If the error persists, run DBCC CHECKCATALOG('YourDatabaseName') WITH NO_INFOMSGS; to rule out deeper metadata corruption, and restore from the last known-good backup if catalog corruption is confirmed.

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

Troubleshooting Guide: Error 7973 – Clustered Columnstore Index Mapping Corruption

Why This Error Happens

Error 7973 occurs when the internal mapping index that links a clustered columnstore index’s delta store rowgroups to their compressed counterparts becomes inconsistent or corrupted. This typically results from an unexpected shutdown during a tuple mover operation, storage-level corruption (bad sectors, faulty I/O), or a failure during a background merge/compression process. In rare cases, it can also surface after restoring a database from a backup that was taken while the columnstore structure was in a transient, inconsistent state.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS, ALL_ERRORMSGS; to identify whether corruption is isolated to the columnstore index or affects underlying base tables.
  • Cross-reference the SQL Server error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for additional 824 or 5180 I/O errors occurring around the same timestamp.
  • Note the exact table and index name reported in the error message for targeted repair.

Step 2: Rebuild the Clustered Columnstore Index

  • Attempt a standard rebuild first, since this often resolves mapping index inconsistencies without data loss:
  • ALTER INDEX [YourCCI_IndexName] ON [dbo].[YourTableName] REBUILD WITH (ONLINE = OFF, MAXDOP = 1);
  • If the rebuild fails or throws the same 7973 error, drop and recreate the index entirely:
  • DROP INDEX [YourCCI_IndexName] ON [dbo].[YourTableName];
  • CREATE CLUSTERED COLUMNSTORE INDEX [YourCCI_IndexName] ON [dbo].[YourTableName];

Step 3: Run Targeted Repair if Rebuild Fails

  • If the index cannot be dropped or rebuilt due to the mapping corruption blocking metadata access, run DBCC CHECKDB (YourDatabaseName, REPAIR_ALLOW_DATA_LOSS) in single-user mode as a last resort.
  • Take the database into single-user mode first via SSMS or:
  • ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Revert to multi-user mode immediately after repair completes:
  • ALTER DATABASE YourDatabaseName SET MULTI_USER;

Step 4: Check Underlying Storage Health

  • Open Event Viewer on Windows Server 2025 and inspect the System log under Windows Logs for Disk or NTFS warning events (Event ID 7, 51, or 153).
  • Run chkdsk D:\ /f /r (replacing D:\ with the volume hosting your .mdf/.ndf files) during a scheduled maintenance window to rule out physical disk-level corruption.

Alternative or Verification Steps

  • After rebuilding, re-run DBCC CHECKDB and query sys.column_store_row_groups to confirm all rowgroups show a state_desc of COMPRESSED or OPEN with no TOMBSTONE anomalies.
  • If corruption recurs frequently, restore the table’s data from the most recent clean backup and re-enable the columnstore index afterward, as repeated 7973 errors often indicate an unresolved hardware-level storage fault.

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

Troubleshooting Guide: SQL Server Error 7970 – “Oldest Active Transaction”

Why This Error Happens

Error 7970 is a warning raised by SQL Server 2025 when the transaction log cannot be truncated due to a long-running active transaction holding the log open. This typically occurs because an application session has an uncommitted transaction (BEGIN TRAN without COMMIT/ROLLBACK), a replication/CDC process is lagging, or an orphaned connection is holding a lock. On Windows Server 2025/Windows 11 hosts, this is often compounded by disk I/O latency or insufficient log file space, which exacerbates the delay in flushing the log.

Step-by-Step Resolution Guide

Step 1: Identify the Oldest Active Transaction

  • Run DBCC OPENTRAN('YourDatabaseName') in SQL Server Management Studio (SSMS) to retrieve the SPID and transaction start time.
  • Note the “Oldest active transaction” timestamp and compare it against current system time to gauge duration.
  • Cross-reference the SPID using sys.dm_exec_sessions and sys.dm_tran_active_transactions to identify the host application or user.

Step 2: Terminate or Resolve the Blocking Session

  • If the SPID belongs to a stalled application or an abandoned connection, run KILL <SPID> in SSMS (replace <SPID> with the actual session ID).
  • Check the application’s connection pooling settings — in web.config or appsettings.json, verify Connection Timeout and ensure transactions are explicitly committed in try/catch blocks.
  • Restart the SQL Server Agent service via Windows Services (services.msc) if a scheduled job is the culprit and is hung.

Step 3: Check for Replication, CDC, or Mirroring Delays

  • Open SQL Server Management Studio > Replication > Monitor to check for stalled Log Reader Agents.
  • Run sp_repldone or sp_replflush cautiously only after confirming replication has fully caught up, to force log truncation markers forward.
  • Validate Change Data Capture (CDC) jobs are running: EXEC sys.sp_cdc_help_jobs.

Step 4: Expand or Relocate the Transaction Log File

  • Navigate to the database file location (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\) and confirm free disk space using File Explorer or Get-PSDrive in PowerShell.
  • In SSMS, right-click the database > Properties > Files, and increase the Log file’s “Autogrowth” increment (e.g., set to 512MB fixed growth instead of percentage-based).
  • If disk space is critically low, move the .ldf file to a separate volume using ALTER DATABASE ... MODIFY FILE syntax, then detach/reattach or restart the SQL Server service.

Step 5: Perform a Manual Log Backup

  • Execute BACKUP LOG YourDatabaseName TO DISK = 'D:\Backups\YourDatabaseName_log.bak' to force truncation of the inactive portion of the log.
  • Confirm the database is in Full or Bulk-Logged recovery model (not Simple) via sys.databases.recovery_model_desc, since Simple recovery handles truncation automatically on checkpoint.

Alternative or Verification Steps

  • Re-run DBCC OPENTRAN('YourDatabaseName') — if it returns “No active open transactions,” the issue is resolved.
  • Monitor the Transaction Log % Used counter in Windows Performance Monitor (perfmon.exe) under the SQLServer:Databases object to confirm log space is no longer climbing toward 100%.

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

Troubleshooting Guide: SQL Server Error 7971

Why This Error Happens

Error 7971 is a diagnostic/informational event raised by SQL Server’s internal consistency checker, typically triggered when a background task (such as a system thread, scheduler monitor, or internal housekeeping process) detects an inconsistency in its expected execution state. This often occurs due to resource contention, orphaned schedulers, or transient memory pressure on the instance. In some cases, it can also surface when third-party filter drivers or antivirus software interfere with SQL Server’s file I/O or thread scheduling on Windows Server 2025/Windows 11.

Step-by-Step Resolution Guide

Step 1: Review the SQL Server Error Log for Context

  • Open SQL Server Management Studio (SSMS) and navigate to Management > SQL Server Logs.
  • Locate the exact timestamp of Error 7971 and note the SPID (%d) and accompanying string (%s) for context.
  • Cross-reference with Windows Event Viewer (Applications and Services Logs > MSSQLSERVER) to check for correlated system-level warnings.

Step 2: Check for Resource Contention and Scheduler Health

  • Run the following query to inspect scheduler status: SELECT * FROM sys.dm_os_schedulers WHERE status != 'VISIBLE ONLINE';
  • Check for high signal_wait_time_ms in sys.dm_os_wait_stats, which may indicate CPU pressure.
  • Verify that Windows Server 2025 power settings are set to “High Performance” (Control Panel > Power Options) to prevent CPU throttling affecting SQL scheduler threads.

Step 3: Exclude SQL Server Files from Antivirus/Filter Drivers

  • Add exclusions for .mdf, .ldf, .ndf files and the SQL Server executable directory (typically C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\) in Windows Defender or third-party antivirus.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER after applying exclusions.

Step 4: Apply Latest Cumulative Update

  • Verify current build version with SELECT @@VERSION;.
  • Download and install the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Update Catalog, as this error is often addressed in maintenance patches targeting internal thread diagnostics.
  • Reboot the server post-installation to ensure all binaries are properly loaded.

Alternative or Verification Steps

  • After applying fixes, monitor the SQL Server Error Log for 24-48 hours to confirm Error 7971 does not recur under normal workload conditions.
  • If the issue persists, run DBCC CHECKDB on all user databases to rule out underlying corruption, and consider opening a support case with Microsoft CSS referencing the specific SPID and error string captured in Step 1.

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

Why This Error Happens

Error 7968 is a diagnostic message that SQL Server writes to the error log when it needs to report details about an active or uncommitted transaction inside a specific database—most commonly during crash recovery, log truncation checks, or when the transaction log is unable to shrink. The root cause is almost always a long-running, orphaned, or uncommitted transaction (often tied to replication, mirroring, Availability Groups, or an application that opened a transaction and never committed/rolled it back) that is holding the log active. In some cases, this message surfaces alongside log file corruption or a VLF (Virtual Log File) that cannot be reused because SQL Server believes a transaction tied to it is still “in-flight.”

Step-by-Step Resolution Guide

Step 1: Identify the Offending Transaction

  • Run DBCC OPENTRAN ('YourDatabaseName') in SQL Server Management Studio (SSMS) to find the oldest active transaction, its SPID, and start time.
  • Cross-reference the SPID using sys.dm_tran_active_transactions and sys.dm_exec_sessions to identify the application, host, and login responsible.

Step 2: Resolve or Terminate the Transaction

  • If the transaction belongs to a known stuck application process, attempt a graceful ROLLBACK TRANSACTION or COMMIT TRANSACTION from the originating session.
  • If the session is orphaned (no longer responding), terminate it safely using KILL <SPID> after confirming it is not part of a critical replication/distributed transaction.
  • For Availability Group or Replication-related transactions, check sys.dm_hadr_database_replica_states or sp_replmonitorsubscriptionpendingcmds to ensure you are not killing a transaction required for synchronization.

Step 3: Check Log File Health and Space

  • Verify the transaction log drive has sufficient free space using Windows File Explorer or Get-PSDrive in PowerShell.
  • Inspect the log file location (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\) for file growth restrictions (ALTER DATABASE YourDatabaseName MODIFY FILE) that may be preventing new VLFs from being allocated.
  • If autogrowth is disabled or capped too low, increase the file size settings via SSMS > Database Properties > Files.

Step 4: Run Consistency Checks on the Database

  • Execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS to rule out underlying corruption triggering the transaction log reporting error.
  • Review the SQL Server error log (via SSMS > Management > SQL Server Logs, or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for any accompanying corruption or I/O error codes (823, 824, 825).

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

  • If the transaction remains stuck despite killing the SPID, restart the SQL Server service via services.msc or Restart-Service -Name 'MSSQLSERVER' in an elevated PowerShell session on Windows Server 2025/Windows 11.
  • Monitor the startup recovery phase in the error log to confirm the transaction rolls back cleanly during the REDO/UNDO phase.

Alternative or Verification Steps

  • After applying the fix, re-run DBCC OPENTRAN ('YourDatabaseName')—a clean result (“No active open transactions”) confirms the issue is resolved.
  • If the error persists after killing sessions and restarting the service, restore the database from the last known good backup in a test environment and run DBCC CHECKDB to rule out log file corruption as the root cause.

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

Troubleshooting Guide: SQL Server Error 7969 — “No Active Open Transactions”

Why This Error Happens

Error 7969 typically occurs when a COMMIT or ROLLBACK statement (often tied to marked transactions, such as WITH MARK or distributed transactions) is issued against a session that has no corresponding open transaction. This commonly happens due to mismatched BEGIN TRAN/COMMIT pairs in application code, a transaction being prematurely closed by an auto-commit setting, or a connection pooling issue in Windows Server 2025 where a stale session reuses a connection that already completed its transaction. It can also surface after a corrupted or interrupted session state caused by network timeouts between the client and SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Review Transaction Code Logic

  • Audit the stored procedure or application script for unbalanced BEGIN TRANSACTION, COMMIT TRANSACTION, and ROLLBACK TRANSACTION statements.
  • Check for nested transactions using SELECT @@TRANCOUNT before issuing a COMMIT to confirm an active transaction exists.
  • Look specifically for marked transactions using BEGIN TRAN ... WITH MARK syntax, as these are the most common trigger for Error 7969.

Step 2: Inspect Connection Pooling and Session State

  • Open SQL Server Management Studio (SSMS) and run DBCC OPENTRAN to check if any transaction is genuinely active on the database.
  • Verify the application’s connection string (e.g., in web.config or appsettings.json) does not have Enlist=false conflicting with distributed transaction coordination.
  • Restart the Distributed Transaction Coordinator (MSDTC) service via services.msc on Windows Server 2025 if distributed transactions are involved.

Step 3: Validate SQL Server Configuration and Patches

  • Confirm SQL Server 2025 is updated to the latest Cumulative Update (CU) via SELECT @@VERSION; to rule out known transaction-handling bugs.
  • Navigate to SQL Server Configuration Manager > SQL Server Network Configuration and ensure no abrupt network interruptions are causing session resets mid-transaction.
  • Increase the connection timeout value in the client driver (e.g., ODBC or SqlConnection string) to prevent premature transaction termination.

Step 4: Clear and Reset the Session

  • If the error persists on a specific session, run KILL <session_id> in SSMS to forcibly terminate the problematic connection (replace <session_id> with the actual SPID from sp_who2).
  • Restart the SQL Server service via PowerShell: Restart-Service -Name 'MSSQLSERVER' to clear any lingering in-memory transaction states.

Alternative or Verification Steps

  • Run DBCC OPENTRAN('YourDatabaseName') after applying the fix; it should return “No active open transactions” only when no transaction is pending, confirming correct behavior rather than an error state.
  • If the issue persists, wrap all transaction logic in a TRY...CATCH block with explicit XACT_STATE() checks to gracefully handle cases where a transaction has already been committed or rolled back by a prior process.

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

Troubleshooting Guide: SQL Server Error 7965 – “Table error: Could not check object ID %d”

Why This Error Happens

Error 7965 typically occurs when DBCC CHECKDB encounters an inconsistency while attempting to validate an object, often due to corrupted pages caused by underlying storage failures, improper shutdowns, or disk I/O errors. This can also stem from insufficient permissions when DBCC attempts to access system metadata tables, or from a damaged allocation structure (IAM/PFS pages) that prevents the engine from mapping the object correctly. In some cases, antivirus or backup software locking database files mid-operation on Windows Server 2025 can trigger this inconsistency.

Step-by-Step Resolution Guide

Step 1: Verify Database and Disk Integrity

  • Open SQL Server Management Studio (SSMS) and run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to capture the full error context.
  • Check the Windows Event Viewer (Application and System logs) for related disk or storage controller errors (Event ID 7, 9, or 51) that might indicate physical disk issues.
  • Run chkdsk C:\ /f /r (replace C:\ with the appropriate drive hosting your .mdf/.ldf files) in an elevated Command Prompt to rule out file system corruption.

Step 2: Review and Reset Permissions

  • Ensure the SQL Server service account has full control over the data directory, typically located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA.
  • Confirm the account running DBCC CHECKDB has db_owner or sysadmin role membership.
  • Use EXEC sp_helprotect 'sys.sysobjects'; to check if system table access has been inadvertently restricted.

Step 3: Isolate and Repair the Corrupted Object

  • Identify the affected object using SELECT OBJECT_NAME(object_id) FROM sys.objects WHERE object_id = <ObjectID>;.
  • Take the database offline or set it to single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;.
  • Run DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS; only after confirming a verified backup exists, as this operation may delete corrupted rows.

Step 4: Restore from a Clean Backup (If Repair Fails)

  • Locate your most recent verified full backup file, typically stored in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Backup\.
  • Restore using: RESTORE DATABASE YourDatabaseName FROM DISK = 'C:\Backup\YourDatabaseName.bak' WITH REPLACE;.
  • Reapply any transaction log backups taken after the full backup to minimize data loss.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; after remediation to confirm zero allocation or consistency errors are returned.
  • If corruption persists, consider exporting clean tables via bcp or SSIS to a new database and decommissioning the damaged one, especially if hardware-level disk failure is suspected.

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

Troubleshooting Guide: Error 7966 — “NO_INDEX Option Being Used” Warning in SQL Server 2025

Why This Error Happens

This warning is raised when DBCC CHECKDB, DBCC CHECKTABLE, or DBCC CHECKFILEGROUP is executed with the NO_INDEX option explicitly specified, either manually or through a maintenance script/job. SQL Server intentionally skips validation of non-clustered, non-system indexes to reduce execution time and I/O load, which means corruption in those index structures will not be detected during that run. This is typically a configuration choice made in legacy maintenance plans rather than an actual engine malfunction, but it can mask underlying index corruption if left unaddressed long-term.

Step-by-Step Resolution Guide

Step 1: Identify Where NO_INDEX Is Being Invoked

  • Review SQL Server Agent Job steps under SQL Server Agent > Jobs in SQL Server Management Studio (SSMS) for any DBCC CHECKDB or DBCC CHECKTABLE commands containing WITH NO_INDEX.
  • Check maintenance plans via Management > Maintenance Plans, specifically the “Check Database Integrity” task properties.
  • Search T-SQL scripts/stored procedures in source control or master.sys.sql_modules for the literal string NO_INDEX.

Step 2: Remove or Replace the NO_INDEX Option

  • Edit the identified job step or script and remove the WITH NO_INDEX clause entirely to allow full index validation:
  DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • If the intent was performance tuning, replace NO_INDEX with PHYSICAL_ONLY instead, which still skips the most expensive logical checks but validates index page structures:
  DBCC CHECKDB ('YourDatabaseName') WITH PHYSICAL_ONLY;

Step 3: Reschedule Full Integrity Checks During Low-Usage Windows

  • Open Task Scheduler or SQL Server Agent > Jobs > New Job and configure a dedicated job to run DBCC CHECKDB without NO_INDEX during off-peak hours (e.g., 2:00 AM–4:00 AM).
  • On Windows Server 2025, ensure the SQL Server service account has sufficient I/O priority by verifying Resource Governor settings aren’t throttling the CHECKDB session.

Step 4: Validate Index Integrity Manually

  • Run a targeted check against suspect tables to confirm indexes are clean:
  DBCC CHECKTABLE ('YourTableName') WITH ALL_ERRORMSGS;
  • Review the SQL Server Error Log (via SSMS > Management > SQL Server Logs) for any follow-up corruption errors (823, 824, 825) that NO_INDEX may have previously suppressed.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS; and confirm Error 7966 no longer appears in the Messages/Results pane or in the Windows Event Viewer under Applications and Services Logs > MSSQLSERVER.
  • If full checks are too resource-intensive for your environment, use PHYSICAL_ONLY as a permanent middle-ground alternative rather than reverting to NO_INDEX, and schedule a full CHECKDB (no options) at least once weekly during a maintenance window.

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

Troubleshooting Guide: Error 7967 – Missing Column Segment in Clustered Columnstore Index

Why This Error Happens

Error 7967 occurs when SQL Server detects that a column segment belonging to a specific rowgroup in a clustered columnstore index is physically missing from the underlying storage structure. This is typically caused by storage-level corruption, an incomplete or interrupted I/O operation during a write/compression delta merge, or disk subsystem failures (such as a crashed storage array or improperly terminated SQL Server process) that left the columnstore’s internal metadata out of sync with actual data segments. It can also surface after restoring a database from an inconsistent backup or after unexpected power loss on the host running Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; in SQL Server Management Studio (SSMS) to validate the extent of corruption.
  • Check the SQL Server error log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related I/O warnings or disk errors around the time of the failure.
  • Use Windows Event Viewer (Windows Logs > System) to check for disk, storage, or NTFS-related errors that coincide with the SQL Server alert.

Step 2: Isolate and Rebuild the Affected Index

  • Identify the exact table and index name referenced in the error message.
  • Attempt an online rebuild first: ALTER INDEX [IndexName] ON [SchemaName].[TableName] REBUILD WITH (ONLINE = ON);
  • If the rebuild fails due to corruption, drop and recreate the clustered columnstore index entirely:
  • DROP INDEX [IndexName] ON [SchemaName].[TableName];
  • CREATE CLUSTERED COLUMNSTORE INDEX [IndexName] ON [SchemaName].[TableName];

Step 3: Restore From a Known-Good Backup

  • If rebuilding fails or corruption persists, restore the affected database from your most recent verified full backup.
  • Use SSMS or T-SQL: RESTORE DATABASE [YourDatabaseName] FROM DISK = 'E:\Backups\YourDatabaseName.bak' WITH REPLACE, RECOVERY;
  • Apply any subsequent transaction log backups to minimize data loss: RESTORE LOG [YourDatabaseName] FROM DISK = 'E:\Backups\YourDatabaseName_log.trn' WITH RECOVERY;

Step 4: Validate Underlying Storage Health

  • Open Windows Server 2025 Disk Management or run chkdsk E: /f /r on the volume hosting your SQL Server data files to rule out ongoing disk-level issues.
  • Review storage controller/RAID logs if running on physical hardware, or check the hypervisor/host logs if running in a virtualized environment (Hyper-V, VMware).
  • Ensure Windows Update and storage driver firmware are current to prevent recurring I/O faults.

Alternative or Verification Steps

  • After rebuilding or restoring, re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to confirm zero allocation or consistency errors are returned.
  • If corruption recurs on the same table shortly after remediation, consider migrating the table to a new filegroup on different physical storage to rule out a failing disk, then re-run DBCC CHECKDB to confirm stability.

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

Troubleshooting Guide: SQL Server Error 7963 – Invalid FILESTREAM LOG File

Why This Error Happens

Error 7963 occurs when the SQL Server Database Engine attempts to read the FILESTREAM log file within a filegroup container, but the file header does not match the expected FILESTREAM log signature. This typically results from an abrupt crash during a FILESTREAM transaction, manual tampering with files inside the FILESTREAM data container directory, or corruption caused by antivirus/backup software locking or modifying files outside of SQL Server’s control. It can also occur if the underlying NTFS volume experienced a failure that corrupted the directory structure used by the FILESTREAM filegroup.

Step-by-Step Resolution Guide

Step 1: Isolate the Affected Database and Stop Write Activity

  • Immediately set the database to RESTRICTED_USER or SINGLE_USER mode to prevent further writes to the corrupted FILESTREAM container.
  • Run: ALTER DATABASE [YourDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Check SQL Server Error Log (via sp_readerrorlog or Event Viewer under Applications and Services Logs > MSSQLSERVER) to confirm the exact container ID referenced in the error.

Step 2: Exclude FILESTREAM Directories from Antivirus and Backup Agents

  • Navigate to the FILESTREAM data container path (commonly found at a path like D:\SQLData\FileStreamContainer\).
  • Add this directory path to the exclusion list in Windows Defender or any third-party antivirus software (Settings > Virus & threat protection > Exclusions).
  • Disable any third-party backup agents (like VSS writers) that might lock files inside this folder during active transactions.

Step 3: Run Database Consistency Checks

  • Open SQL Server Management Studio (SSMS) and execute a full consistency check to identify the scope of corruption.
  • Run: DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • If the FILESTREAM log file (filestream.hdr or similar internal log tracking files) is confirmed corrupt and no repair option resolves it, proceed to restore from the last known good backup.

Step 4: Restore from Backup or Remove Corrupt Filegroup

  • If DBCC CHECKDB reports unrepairable FILESTREAM filegroup corruption, perform a piecemeal restore targeting only the specific damaged filegroup if the rest of the database is healthy.
  • Alternatively, run: RESTORE DATABASE [YourDB] FILE='FileStreamGroup' FROM DISK = 'D:\Backups\YourDB.bak' WITH RECOVERY;
  • If no backup exists, you may need to remove the broken filegroup reference and recreate the FILESTREAM column using ALTER TABLE... DROP COLUMN, accepting data loss for that specific BLOB data.

Alternative or Verification Steps

  • To verify the fix, set the database back to MULTI_USER mode and run DBCC CHECKDB again; the error 7963 should no longer appear in the output.
  • If the issue persists immediately after a restore, verify that the Windows user account running the SQL Server service has full Read/Write/Modify NTFS permissions on the parent directory of the FILESTREAM container, as permission resets during OS migrations to Windows Server 2025 can sometimes mimic corruption errors.

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

Troubleshooting Guide: SQL Server Error 7964

Why This Error Happens

Error 7964 is raised by DBCC CHECKDB (or CHECKTABLE) during the repair phase when it encounters a FILESTREAM file that has no corresponding valid record in the table’s data pages, making it an orphaned file. This typically occurs after unexpected server shutdowns, storage-level corruption, or manual tampering with the FILESTREAM data container outside of SQL Server’s control. Because the repair option (REPAIRALLOWDATA_LOSS) removes the orphaned file to restore internal consistency, the underlying BLOB data referenced by that column ID is permanently lost.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; without a repair clause first to capture a full list of errors.
  • Review the SQL Server error log (default path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related FILESTREAM warnings.
  • Identify the affected column ID and table name referenced in the error message.

Step 2: Take a Full Backup Before Repair

  • Execute BACKUP DATABASE [YourDatabaseName] TO DISK = 'D:\Backups\PreRepair_YourDatabaseName.bak' WITH INIT, COMPRESSION;
  • Store this backup separately in case you need to attempt data recovery from the FILESTREAM container manually before repair runs.
  • Verify the backup completed successfully using RESTORE VERIFYONLY FROM DISK = 'D:\Backups\PreRepair_YourDatabaseName.bak';

Step 3: Set Database to Single-User Mode and Repair

  • Run ALTER DATABASE [YourDatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Execute DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Allow the command to complete fully; it will delete the orphaned FILESTREAM file(s) referenced by the column ID in the error.

Step 4: Restore Multi-User Access and Inspect the FILESTREAM Container

  • Run ALTER DATABASE [YourDatabaseName] SET MULTI_USER;
  • Navigate to the FILESTREAM data container path (e.g., D:\SQLData\FileStreamData\) and confirm the orphaned file referenced in the original error no longer exists.
  • Check NTFS permissions on the FILESTREAM folder to ensure the SQL Server service account has Full Control, as misconfigured ACLs can cause repeated orphaning.

Step 5: Re-run Integrity Check to Confirm Resolution

  • Execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; again.
  • Confirm no further Error 7964 or related FILESTREAM consistency errors are reported.

Alternative or Verification Steps

  • Query sys.database_files and cross-reference the FILESTREAM column data using SELECT * FROM sys.filestream_tombstone_2; to confirm no lingering orphaned references remain.
  • If data loss from the deleted FILESTREAM file is unacceptable, restore the pre-repair backup to a separate instance and manually extract the BLOB data from the file system before accepting the repair on production.

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

Troubleshooting Guide: Error 7962 – Invalid BATCHID Specified

Why This Error Happens

Error 7962 in SQL Server 2025 typically occurs when the internal tracking mechanism for a DBCC batch operation (such as DBCC CHECKDB or online index rebuild batches) references a BATCHID that no longer exists in the sys.dm_exec_background_job_queue or internal batch metadata tables. This usually happens due to a premature termination of a previous maintenance job, corruption in the msdb system database, or a race condition where concurrent sessions attempt to reference a batch that has already been purged by the cleanup job. In some cases, this is triggered by orphaned entries left behind after an unexpected SQL Server service restart on Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the Invalid BATCHID

  • Open SQL Server Management Studio (SSMS) and query the error log using EXEC sp_readerrorlog 0, 1, 'BATCHID'; to find the exact %d value reported.
  • Cross-reference the ID against msdb.dbo.syssessions and msdb.dbo.sysjobhistory to determine which job or session originated the request.
  • Check if the SQL Server Agent service was recently restarted via Event Viewer under Windows Logs > System.

Step 2: Clear Orphaned Batch Metadata

  • Stop the SQL Server Agent service via services.msc or by running net stop SQLSERVERAGENT in an elevated Command Prompt.
  • Run the built-in consistency repair utility: DBCC CHECKDB('msdb') WITH NO_INFOMSGS, ALL_ERRORMSGS; to detect metadata corruption in the system database.
  • If corruption is found in batch tracking tables, restore msdb from a recent clean backup located typically at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Backup\.

Step 3: Rebuild the Internal Batch Queue

  • Restart the SQL Server service fully (not just Agent) using net stop MSSQLSERVER followed by net start MSSQLSERVER to force a clean reinitialization of the in-memory batch queue.
  • Re-run the original failed operation (e.g., DBCC CHECKDB, index rebuild, or Stretch Database batch sync) to confirm a new, valid BATCHID is generated.
  • Monitor SQL Server Configuration Manager to ensure no duplicate instances are fighting over the same batch resource pool.

Step 4: Apply Latest Cumulative Update

  • Verify your current build number by running SELECT @@VERSION; in a query window.
  • Navigate to the Microsoft Update Catalog and download the latest Cumulative Update (CU) for SQL Server 2025, as this specific error code is often patched in minor metadata-handling bug fixes.
  • Install the update and reboot the Windows Server 2025 host to ensure driver and service dependencies refresh correctly.

Alternative or Verification Steps

  • Verification: Re-execute the query or maintenance job that originally failed; if Error 7962 does not reappear in the SQL Server Error Log (viewable via SSMS > Management > SQL Server Logs), the fix was successful.
  • Alternative: If the error persists after a service restart, create a brand new SQL Server Agent job to handle the batch task rather than reusing the old job definition, as the old job’s internal GUID may still be flagged as invalid in the metadata cache.

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

Troubleshooting Guide: SQL Server Error 7960

Why This Error Happens

Error 7960 occurs when a monitoring query, administrative command, or client application references a Server Process ID (SPID) or batch ID that no longer exists in the SQL Server engine’s internal process table. This typically happens because the session terminated, disconnected, or completed execution in the brief interval between when the SPID was captured (e.g., from sys.sysprocesses or sys.dm_exec_requests) and when it was subsequently referenced by a command like KILL or DBCC INPUTBUFFER. It can also occur due to a stale connection pool reference or a third-party monitoring tool caching an outdated SPID value.

Step-by-Step Resolution Guide

Step 1: Re-Validate the SPID Before Re-Issuing the Command

  • Do not reuse a previously captured SPID value from a script or monitoring dashboard without refreshing it first.
  • Run the following to get a live, current list of active sessions:
SELECT session_id, status, login_name, host_name 
FROM sys.dm_exec_sessions 
WHERE is_user_process = 1;
  • Confirm the SPID in question is actually present in the result set before issuing KILL <SPID> or DBCC INPUTBUFFER(<SPID>).

Step 2: Check for Race Conditions in Automation Scripts or Jobs

  • If this error originates from a SQL Server Agent Job, PowerShell script, or custom monitoring tool, inspect the logic for a time gap between SPID collection and SPID action.
  • Add a validation check immediately before execution:
IF EXISTS (SELECT 1 FROM sys.dm_exec_sessions WHERE session_id = @SPID)
BEGIN
    KILL @SPID;
END
  • Reduce polling intervals in monitoring tools to minimize the window where a SPID can expire.

Step 3: Update SQL Server 2025 Cumulative Updates

  • Navigate to Microsoft Update Catalog or use SQL Server Setup > Maintenance > Check for Updates to ensure you’re on the latest Cumulative Update (CU) for SQL Server 2025.
  • Older DMV query engines occasionally have timing edge cases with rapidly cycling batch IDs; current patches resolve several of these race condition bugs.
  • Verify build version with:
SELECT @@VERSION;

Step 4: Inspect Connection Pooling and Application-Side Caching

  • If the error is thrown by an application layer (e.g., .NET, Java, or a custom admin panel) rather than ad-hoc T-SQL, check if the app is caching SPID/connection identifiers across pooled connections.
  • On Windows Server 2025 / Windows 11, open ODBC Data Source Administrator (odbcad32.exe) and confirm connection pooling settings aren’t retaining stale session handles longer than the SQL Server session timeout.
  • Adjust the application’s connection timeout or disable aggressive connection reuse if stale SPIDs persist.

Step 5: Review SQL Server Error Log for Correlated Session Terminations

  • Navigate to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG (adjust instance folder name as needed for your SQL Server 2025 installation).
  • Search for session termination or disconnect events occurring at the same timestamp as the Error 7960 entry to confirm the SPID expired naturally rather than due to corruption.

Alternative or Verification Steps

  • Re-run your original monitoring or kill command immediately after confirming the SPID exists via sys.dm_exec_sessions; if it succeeds without Error 7960, the issue was a timing race condition and is now resolved.
  • If the error persists even with freshly validated SPIDs, restart the SQL Server (MSSQLSERVER) service via services.msc on Windows Server 2025 to rule out a corrupted internal process table, then retest.

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

Microsoft SQL Server 2025 Error 7961: Troubleshooting Guide

Why This Error Happens

Error 7961 occurs when SQL Server’s consistency checker (DBCC CHECKDB) detects that the metadata for a specific Object ID is corrupted or inconsistent with the system catalog views. This typically results from incomplete transactions during a power failure, storage-level corruption (bad sectors, faulty RAID controllers), or improper shutdowns of the SQL Server service. In rarer cases, it can stem from bugs in third-party backup or antivirus tools that lock or modify database files mid-write operation.

Step-by-Step Resolution Guide

Step 1: Isolate the Database and Confirm the Scope of Corruption

  • Open SQL Server Management Studio (SSMS) and run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Note the specific Object ID (%d) referenced in the error and cross-reference it using SELECT OBJECT_NAME(object_id) FROM sys.objects WHERE object_id = <ID>;
  • Check the SQL Server Error Log (via Get-Content "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG" in PowerShell) for correlating I/O warnings.

Step 2: Verify Hardware and Storage Integrity

  • On Windows Server 2025/Windows 11, run chkdsk C: /f /r (or the relevant drive letter hosting the .mdf/.ldf files) and schedule a reboot if the volume is in use.
  • Check Event Viewer under Windows Logs > System for Disk or NTFS warnings (Event ID 7 or 55) that indicate physical sector failures.
  • If using a SAN or virtualized storage layer, validate the underlying disk health through the storage vendor’s diagnostic utility.

Step 3: Repair the Corrupted Object via Controlled Restore

  • Restore the database from the last known good backup using RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDatabase.bak' WITH REPLACE; if a clean backup exists.
  • If no backup is viable, isolate the object and attempt DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) only as a last resort, ideally on a copy of the database rather than production.
  • Set the database to single-user mode first using ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE; before running repair operations.

Step 4: Harden the Environment to Prevent Recurrence

  • Enable Instant File Initialization and verify Write Caching is disabled on the physical disk controller (Device Manager > Disk Drives > Policies tab) to prevent torn-page writes.
  • Configure SQL Server to use CHECKSUM page verification by running ALTER DATABASE YourDatabaseName SET PAGE_VERIFY CHECKSUM;
  • Schedule a recurring SQL Server Agent job to run DBCC CHECKDB weekly during low-traffic windows.

Alternative or Verification Steps

  • After remediation, re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm it returns “0 allocation errors and 0 consistency errors.”
  • If corruption persists on the same Object ID after a restore, treat it as a hardware fault and move the database files to a different physical volume or VM host before re-attaching.

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

Troubleshooting Guide: Error 7957 – Cannot Display SPID Buffer (In Transition)

Why This Error Happens

Error 7957 occurs when SQL Server’s DBCC commands (such as DBCC INPUTBUFFER or DBCC OUTPUTBUFFER) attempt to read the input/output buffer of a Session ID (SPID) that is currently in a transitional state. This typically happens because the target session is rapidly switching between execution states (e.g., parallel query coordination, session termination, or connection pooling resets) faster than the Session Information Manager can lock and report its buffer data. It is a timing/concurrency issue rather than a permissions or corruption issue, as the specific worker thread is temporarily unavailable for inspection at the exact moment of the query.

Step-by-Step Resolution Guide

Step 1: Verify the Target SPID Status

  • Run sp_who2 active or query sys.dm_exec_sessions to confirm if the SPID is still active or has already disconnected.
  • Check the status column for values like “background” or “sleeping,” which often trigger transition errors when probed.
  • Avoid running DBCC INPUTBUFFER on system SPIDs (typically IDs below 50) as these are reserved for internal processes and rarely yield readable buffers.

Step 2: Retry Using Dynamic Management Views (DMVs)

  • Since DBCC commands can fail during transition, pivot to sys.dm_exec_connections and sys.dm_exec_sql_text for a more stable snapshot.
  • Execute the following query to bypass the transitional locking issue:
  SELECT text FROM sys.dm_exec_requests
  CROSS APPLY sys.dm_exec_sql_text(sql_handle)
  WHERE session_id = <Your_SPID>;
  • This method reads from the cache rather than attempting a live lock on the transitioning thread.

Step 3: Check for Parallelism and CXPACKET Waits

  • Open SQL Server Management Studio (SSMS) and navigate to Activity Monitor.
  • Look for high CXPACKET or CXCONSUMER wait types associated with the SPID, as parallel threads often cause the “in transition” state when the DBCC command targets a parent thread managing child threads.
  • If found, consider adjusting the MAXDOP (Max Degree of Parallelism) setting for the specific query or server instance to reduce thread-switching conflicts:
  • Navigate to Server Properties > Advanced > Max Degree of Parallelism in SSMS.

Step 4: Restart the SQL Server Service (If Persistent)

  • If the error persists across multiple different SPIDs, it may indicate a resource bottleneck on the host.
  • On Windows Server 2025, open Services.msc.
  • Locate SQL Server (MSSQLSERVER) or the named instance, right-click, and select Restart.
  • Note: Ensure no critical transactions are pending before restarting, as this will terminate all current connections.

Alternative or Verification Steps

  • Verification: Re-run the DBCC INPUTBUFFER(<SPID>) command after a 5-10 second delay; if the thread has settled, the error should resolve and return the input buffer text.
  • Alternative: If the issue persists specifically on Windows 11 development environments, use Extended Events (XEvents) to capture the sql_text and session_id via the sql_statement_completed event instead of relying on legacy DBCC commands.

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

Troubleshooting Guide: SQL Server Error 7958

Why This Error Happens

Error 7958 occurs when DBCC commands (such as DBCC INPUTBUFFER or DBCC OUTPUTBUFFER) attempt to read the input/output buffer of a Session ID (SPID) that is not actively processing a request or has already completed execution. This typically happens because the target session is sleeping, awaiting a client connection, or has been terminated between the time it was identified and the time the DBCC command was executed. It can also occur if the SPID belongs to a system process or background task that does not maintain a readable I/O buffer at that moment.

Step-by-Step Resolution Guide

Step 1: Verify the SPID Is Still Active

  • Run SELECT session_id, status, command FROM sys.dm_exec_requests WHERE session_id = <SPID>; to confirm the session exists.
  • Check if the status column shows “sleeping” or “background” — these states often cannot return buffer data.
  • If the SPID no longer appears in sys.dm_exec_sessions, the connection has already closed and the error is expected behavior.

Step 2: Re-run DBCC Commands Immediately After Capture

  • Capture the SPID using SELECT * FROM sys.dm_exec_connections WHERE session_id = <SPID>; and immediately execute DBCC INPUTBUFFER(<SPID>); in the same batch.
  • Avoid delays between identifying the SPID and running the DBCC command, since the session state can change within milliseconds under high concurrency.
  • Use sys.dm_exec_sql_text(sql_handle) as an alternative method to retrieve the last executed statement without relying on DBCC buffer reads.

Step 3: Check for Blocking or Killed Sessions

  • Query sys.dm_os_waiting_tasks to determine if the SPID was blocked and subsequently rolled back before you issued the command.
  • Review the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for corresponding KILL or disconnect events around the same timestamp.
  • If the session was manually killed via KILL <SPID>;, this is the expected cause and not a configuration fault.

Step 4: Update SQL Server 2025 Cumulative Updates

  • Open SQL Server Configuration Manager and confirm the current build version under SQL Server Services.
  • Apply the latest Cumulative Update (CU) via Microsoft Update Catalog, as early 2025 builds contain a known timing issue in the DMV snapshot engine affecting transient SPIDs.
  • Restart the SQL Server service through services.msc after the update installs.

Alternative or Verification Steps

  • Re-run the DBCC command against a known active, long-running SPID (e.g., a session executing a large query) to confirm the buffer reads correctly, verifying the fix works for valid sessions.
  • As an alternative, use Extended Events (sqlserver.sql_batch_starting and sqlserver.sql_batch_completed) to capture query text instead of relying on DBCC INPUTBUFFER/OUTPUTBUFFER for transient sessions.

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

Troubleshooting Guide: Error 7959 – Columnstore Index Missing Dictionaries

Why This Error Happens

Error 7959 occurs when the internal dictionary pages associated with a columnstore index are missing, corrupted, or out of sync with the segment data they support. This is typically caused by physical page-level corruption on disk (due to faulty storage hardware, improper shutdowns, or disk subsystem errors), incomplete transaction rollbacks during a crash, or bugs triggered during bulk load operations that were interrupted mid-compression. Since columnstore indexes rely heavily on dictionary pages to decode compressed segment data, any gap between the metadata and the actual storage pages renders the index unreadable.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and connect to the affected instance.
  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to get a full corruption report.
  • Look specifically for allocation errors referencing the columnstore object ID and partition ID to isolate exactly which table is affected.

Step 2: Isolate and Rebuild the Specific Index

  • Identify the exact non-clustered columnstore index name using sys.indexes and sys.partitions.
  • Attempt a targeted rebuild rather than a full database repair first, as this is non-destructive: ALTER INDEX [YourColumnstoreIndexName] ON [dbo].[YourTableName] REBUILD;
  • If the table is large, rebuild a specific partition only to save time: ALTER INDEX [YourColumnstoreIndexName] ON [dbo].[YourTableName] REBUILD PARTITION = 5;

Step 3: Restore From a Clean Backup (If Rebuild Fails)

  • If the rebuild command fails or hangs due to underlying page corruption, the storage engine cannot read the base data needed to rebuild.
  • Navigate to your backup directory (e.g., D:\SQLBackups\) and locate the most recent full backup taken before the corruption event.
  • Restore the database to a new name to verify integrity: RESTORE DATABASE [YourDB_Recovery] FROM DISK = 'D:\SQLBackups\YourDB.bak' WITH REPLACE;
  • Export the specific missing data from the recovered copy into the production table using INSERT INTO ... SELECT or the Import/Export Wizard.

Step 4: Emergency Repair (Last Resort)

  • If no clean backup exists, you may need to force repair, though this risks data loss for the specific rows involved.
  • Set the database to single-user emergency mode: ALTER DATABASE YourDatabaseName SET EMERGENCY, SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run the repair command, acknowledging that minimal data loss is possible: DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);
  • Return the database to multi-user mode immediately after: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Alternative or Verification Steps

  • After rebuilding, run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS; a second time to confirm the error code 7959 no longer appears in the results.
  • As a long-term fix, run Windows Memory Diagnostic and check the Event Viewer (Windows Logs > System) for Event ID 51/153 disk errors, as recurring columnstore corruption is often a symptom of failing physical storage hardware rather than a SQL Server software bug.

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

Troubleshooting Guide: Error 7955 — “Invalid SPID %d Specified”

Why This Error Happens

Error 7955 occurs when a DBCC command, monitoring script, or administrative query references a Session Process ID (SPID) that no longer exists or was never valid in the current server context. This typically happens because the session has already terminated, disconnected, or been killed by the time the command executes, creating a race condition between session state and the command targeting it. It can also occur when a script hardcodes a SPID value instead of dynamically querying sys.dm_exec_sessions or sys.sysprocesses, or when the SPID belongs to an internal system process that doesn’t support the requested operation.

Step-by-Step Resolution Guide

Step 1: Verify the SPID Currently Exists

  • Run the following query to confirm whether the SPID is active before issuing any commands against it:
  • SELECT session_id, status, login_name FROM sys.dm_exec_sessions WHERE session_id = <your_SPID>;
  • If no rows are returned, the session has already closed and the original command is referencing a stale value.
  • Check Windows Event Viewer under Applications and Services Logs > MSSQLSERVER for correlating connection/disconnection timestamps.

Step 2: Eliminate Hardcoded or Cached SPID Values in Scripts

  • Open the script, SSMS job step, or monitoring tool that triggered the error.
  • Replace any static SPID number with a dynamic lookup, for example:
  • DECLARE @spid INT = (SELECT session_id FROM sys.dm_exec_sessions WHERE login_name = 'YourLoginName');
  • Ensure scheduled SQL Agent jobs re-query the SPID immediately before execution rather than reusing a value captured earlier in the job flow.

Step 3: Check for Race Conditions in Automation Tools

  • If a third-party monitoring tool (e.g., performance dashboards, custom kill-scripts) is generating this error, confirm its polling interval.
  • Increase the interval between “detect SPID” and “action on SPID” steps to reduce the chance the session closes mid-process.
  • On Windows Server 2025 / Windows 11, confirm the SQL Server Agent service account has adequate permissions under Services.msc > SQL Server Agent > Log On to avoid delayed execution caused by permission re-validation.

Step 4: Rule Out System SPID Misuse

  • SPIDs below 50 are reserved for internal SQL Server system processes and cannot be killed or targeted with most DBCC commands.
  • Run SELECT * FROM sys.dm_exec_sessions WHERE session_id < 50; to confirm whether the SPID in question is a system process.
  • Adjust your script or command to explicitly exclude system SPIDs from targetable ranges.

Step 5: Update SQL Server 2025 Cumulative Updates

  • Navigate to Microsoft Update Catalog or use SQL Server Setup > Maintenance to check for the latest Cumulative Update.
  • Apply the update, as session-handling race conditions are occasionally patched in CU releases.
  • Restart the SQL Server (MSSQLSERVER) service via Services.msc after installation.

Alternative or Verification Steps

  • Re-run the original DBCC or kill command immediately after confirming the SPID exists via sys.dm_exec_sessions; if the error no longer appears, the issue was a timing/race condition rather than a configuration fault.
  • If the error persists on valid, currently active SPIDs, capture a SQL Server Profiler trace or Extended Events session filtering on Error 7955 to identify the exact calling context, then escalate to Microsoft Support with the trace file attached.

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

Troubleshooting Guide: Error 7956 – FILESTREAM Container Mismatch

Why This Error Happens

This error occurs when the internal metadata tracking a FILESTREAM file’s location becomes inconsistent with the actual FILESTREAM directory structure on disk, typically pointing to Container ID mismatches recorded in the sys.filestream_tombstone or internal directory objects. This corruption is most often triggered by improper shutdowns during large FILESTREAM write operations, a failed or interrupted storage migration, or underlying disk/storage subsystem corruption (e.g., SAN failover issues or NTFS corruption). It can also surface after a restore operation where the FILESTREAM container garbage collection process did not complete correctly before the backup was taken.

Step-by-Step Resolution Guide

Step 1: Run a Diagnostic Check to Confirm Scope

  • Open SQL Server Management Studio (SSMS) and execute DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS, ALL_ERRORMSGS; to confirm if the corruption is isolated to the FILESTREAM data or if it extends to standard database pages.
  • Note the specific object_ID and container_ID referenced in the error output to identify the exact table causing the conflict.
  • Check the Windows Event Viewer (Applications and Services Logs > MSSQLSERVER) for correlating disk I/O errors (Event ID 823 or 824) that might indicate the root cause is hardware-based.

Step 2: Isolate the FILESTREAM Filegroup

  • Take the specific FILESTREAM filegroup offline if possible, or restrict access to the specific table to prevent further writes to the corrupted container.
  • Use ALTER DATABASE [YourDatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; to ensure no other processes are writing to the FILESTREAM directory during repair, as concurrent writes can exacerbate the container ID conflict.
  • Navigate to the physical FILESTREAM data path (usually found via SELECT * FROM sys.database_files;) to visually inspect the folder structure for the mismatched container IDs noted in Step 1.

Step 3: Execute Repair with Data Loss Allowance

  • Since FILESTREAM container pointer errors are rarely fixable without data loss, run DBCC CHECKDB (YourDatabaseName, REPAIR_ALLOW_DATA_LOSS) in single-user mode.
  • Note: This command will deallocate the corrupted FILESTREAM pointer and realign the metadata, but it may result in the loss of the specific BLOB data associated with the orphaned container ID.
  • Once the command completes, switch the database back to multi-user mode using ALTER DATABASE [YourDatabaseName] SET MULTI_USER;.

Step 4: Restore From a Clean Backup (If Repair Fails)

  • If REPAIR_ALLOW_DATA_LOSS does not resolve the container mismatch (common in severe NTFS-level corruption), perform a full restore of the database and associated FILESTREAM filegroups from the last known good backup.
  • Ensure you restore to a different physical path initially to prevent overwriting the corrupted container directories, specifically targeting the WITH MOVE clause for the FILESTREAM data path in Windows Server 2025 environments.

Alternative or Verification Steps

  • Verification: After running the repair or restore, execute DBCC CHECKDB again with no repair options to ensure the error count for Msg 7956 returns to zero and the FILESTREAM container IDs match the object IDs correctly.
  • Alternative: If corruption persists across multiple FILESTREAM containers, use sp_filestream_configure to temporarily disable and re-enable FILESTREAM access at the instance level, forcing SQL Server to rebuild the directory structure mapping upon service restart.

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

Why This Error Happens

Error 7953 occurs when SQL Server 2025’s Storage Engine detects a mismatch between the actual free space on a data page and the value tracked in the corresponding Page Free Space (PFS) interval page. This is typically triggered when running legacy fragmentation commands like DBCC SHOWCONTIG, which calculates the “Avg. Bytes Free per Page” metric by reading PFS byte-maps that have become desynchronized due to an unexpected service termination, a failed checkpoint, or underlying disk-level corruption. In Windows Server 2025 environments, this is frequently exacerbated by ReFS volume misconfigurations or antivirus software locking .mdf/.ndf files during a write operation, causing SQL Server to write a “dirty” page header that doesn’t match its PFS record.

Step-by-Step Resolution Guide

Step 1: Verify Database Integrity via DBCC CHECKDB

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio connected to your 2025 instance.
  • Run the following command to scan for physical corruption without immediately attempting repairs:
  DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output for allocation errors (specifically Msg 8909 or 8928) that often accompany a 7953 event regarding PFS pages.

Step 2: Migrate Away from Deprecated DBCC SHOWCONTIG

  • Since DBCC SHOWCONTIG is fully deprecated in SQL Server 2025 and is the primary trigger for this specific error string, replace any legacy maintenance scripts with the Dynamic Management View (DMV) equivalent.
  • Execute the following query to get fragmentation and free space data without touching legacy PFS parsing logic:
  SELECT * FROM sys.dm_db_index_physical_stats 
  (DB_ID(), OBJECT_ID('YourTableName'), NULL, NULL, 'DETAILED');
  • Update any SQL Agent Jobs located in SQL Server Agent > Jobs that reference the old command syntax.

Step 3: Check for File System Locking Conflicts (Windows Server 2025)

  • Navigate to the Windows Defender settings via Windows Security > Virus & threat protection > Manage settings.
  • Add exclusions for your SQL Server data directories to prevent file-locking race conditions that cause PFS corruption:
  • C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\
  • Restart the SQL Server (MSSQLSERVER) service via services.msc to clear any stale file handles.

Step 4: Repair Corrupted Pages (If Integrity Check Fails)

  • If Step 1 confirmed corruption, take the database offline and restore from the last known good backup if possible.
  • If a backup is unavailable, run the repair command as a last resort (Note: this may result in data loss):
  ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);
  ALTER DATABASE YourDatabaseName SET MULTI_USER;

Alternative or Verification Steps

  • Verification: Re-run DBCC CHECKDB after applying the fixes; a clean output with “0 allocation errors and 0 consistency errors” confirms the PFS mismatch causing Error 7953 has been resolved.
  • Alternative: If the error persists only during specific maintenance windows, check the Windows Event Viewer (Application and Services Logs > MSSQLSERVER) for correlating Disk I/O timeout warnings, as this suggests a hardware-level fix (updating RAID controller drivers) is needed rather than a software-level fix.

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

Why This Error Happens

Error 7954 is generated by the Database Engine when DBCC SHOWCONTIG (or legacy fragmentation-reporting code paths invoked internally by DBCC CHECKDB) cannot cleanly calculate page density statistics because of insufficient tempdb workspace or because the index pages being scanned contain corrupted density/row-count metadata. In SQL Server 2025, this is most often triggered when tempdb has run out of free space mid-scan, causing the engine to return a malformed message buffer (visible as the raw %4.2f%ls format string instead of a resolved percentage value). A secondary cause is outdated statistics or allocation map corruption on the table/index being analyzed, which prevents the formatter from substituting real values into the message template.

Step-by-Step Resolution Guide

Step 1: Verify and Expand tempdb Capacity

  • Open SQL Server Management Studio (SSMS) and run EXEC sp_helpdb tempdb; to check current file size and autogrowth settings.
  • Navigate to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\ and confirm the tempdb.mdf and templog.ldf files have free disk space available on the volume.
  • Increase tempdb size manually: ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, SIZE = 5120MB, FILEGROWTH = 512MB);

Step 2: Run DBCC CHECKDB to Rule Out Corruption

  • Execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; against the affected database.
  • Review the output for allocation errors (Msg 8909, 8928) that may be the real source of malformed density statistics.
  • If corruption is found, restore from the last known good backup rather than using REPAIR_ALLOW_DATA_LOSS as a first resort.

Step 3: Update Statistics and Rebuild Fragmented Indexes

  • Run EXEC sp_updatestats; on the target database to refresh outdated statistics that may be feeding bad data into the density calculation.
  • Rebuild heavily fragmented indexes identified via sys.dm_db_index_physical_stats: ALTER INDEX ALL ON dbo.YourTable REBUILD WITH (ONLINE = ON);

Step 4: Apply Latest SQL Server 2025 Cumulative Update

  • Check the installed build via SELECT @@VERSION; and compare against the latest Cumulative Update (CU) listed on the Microsoft Update Catalog for SQL Server 2025.
  • Install the CU using the standard setup wizard or silent install: Setup.exe /quiet /action=Patch /IAcceptSQLServerLicenseTerms /instancename=MSSQLSERVER.
  • Reboot the Windows Server 2025 host if prompted, since this error has been linked to a formatting bug patched in early 2025 CUs.

Alternative or Verification Steps

  • Re-run DBCC SHOWCONTIG('YourTable') WITH TABLERESULTS; after completing the steps above — the Avg. Page Density value should now display as a proper percentage instead of the raw format string.
  • If the error persists, switch to the modern equivalent SELECT * FROM sys.dm_db_index_physical_stats(DB_ID(), OBJECT_ID('YourTable'), NULL, NULL, 'DETAILED');, which bypasses the legacy DBCC SHOWCONTIG formatting code entirely.

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

Troubleshooting Guide: SQL Server Error 7951 – FILESTREAM Consistency Check Failure

Why This Error Happens

Error 7951 occurs when SQL Server’s DBCC CHECKDB process attempts to validate FILESTREAM data but cannot access the filesystem directory where FILESTREAM BLOBs are stored. This is typically caused by the SQL Server service account lacking sufficient NTFS permissions on the FILESTREAM data container, the FILESTREAM share being temporarily unavailable (e.g., due to antivirus locks or disk I/O contention), or an underlying storage/volume issue such as a disconnected network share or corrupted NTFS volume. Because the warning explicitly states the condition is “likely transient,” it often points to a timing or locking conflict rather than permanent corruption.

Step-by-Step Resolution Guide

Step 1: Verify FILESTREAM Service Account Permissions

  • Open File Explorer and navigate to the FILESTREAM data directory (commonly found under the path specified in sys.database_files for the FILESTREAM filegroup, e.g., D:\SQLData\FileStreamData).
  • Right-click the folder, select Properties > Security, and confirm the SQL Server service account (e.g., NT SERVICE\MSSQLSERVER) has Full Control.
  • If permissions are missing, click Edit > Add, enter the service account name, and grant Full Control, then click Apply.

Step 2: Check for File Locks or Antivirus Interference

  • Use Resource Monitor (resmon.exe) to check if any process is locking files in the FILESTREAM directory under the CPU > Associated Handles tab.
  • Temporarily disable real-time antivirus scanning on the FILESTREAM folder path to rule out scan-lock conflicts.
  • Add a permanent antivirus exclusion for the FILESTREAM data directory and the SQL Server .mdf/.ldf/.ndf paths.

Step 3: Validate Disk and Volume Health

  • Run chkdsk D: /f /r (replace D: with your actual FILESTREAM volume) from an elevated Command Prompt to check for underlying disk corruption.
  • Confirm the volume is NTFS-formatted and not approaching capacity limits, as low disk space can cause transient I/O failures.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc to clear any stale file handles.

Step 4: Re-run Consistency Checks

  • Execute DBCC CHECKDB ('YourDatabaseName') WITH DATA_PURITY, ALL_ERRORMSGS, NO_INFOMSGS; in SQL Server Management Studio (SSMS).
  • Review the SQL Server Error Log (Management > SQL Server Logs in SSMS) for any additional error codes referenced alongside 7951 (e.g., 5901 or 8992).

Alternative or Verification Steps

  • Re-run DBCC CHECKDB immediately after completing the steps above; if Error 7951 does not reappear and no FILESTREAM-related errors are logged, the issue is resolved.
  • If the problem persists, fail the FILESTREAM filegroup over to a different physical disk/volume using ALTER DATABASE ... MODIFY FILE, then rerun the consistency check to confirm whether the original storage hardware was the root cause.

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

Microsoft SQL Server 2025 — Error 7952: Extent Scan Fragmentation Reporting Failure

Why This Error Happens

Error 7952 typically surfaces during a DBCC SHOWCONTIG or similar integrity-checking operation when SQL Server encounters inconsistent internal page-allocation metadata while calculating extent fragmentation statistics. This is most often caused by a corrupted or partially written system catalog page (often within sysindexes or the IAM chain) resulting from an unexpected shutdown, storage-level interruption, or antivirus/backup software locking database files mid-write. In some Windows Server 2025 / Windows 11 environments, this is compounded by misconfigured storage drivers (NVMe or ReFS) that fail to properly flush cached writes to disk.

Step-by-Step Resolution Guide

Step 1: Verify Database Integrity

  • Open SQL Server Management Studio (SSMS) or sqlcmd and run:
  DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output for allocation errors tied to extent/page IDs referenced by Error 7952.
  • Note any corrupted object IDs for targeted repair in later steps.

Step 2: Isolate and Stop Conflicting I/O Processes

  • Check Windows Event Viewer under Windows Logs > System for disk or storage controller warnings (Event ID 153 or 129) occurring around the same timestamp.
  • Temporarily disable third-party antivirus or backup agents that scan .mdf/.ldf files:
  • Navigate to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\
  • Add this path to your antivirus exclusion list permanently.
  • Restart the SQL Server service via services.msc or:
  Restart-Service -Name 'MSSQLSERVER' -Force

Step 3: Repair Corrupted Extents

  • Put the database in single-user mode:
  ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run the repair command matching the severity reported by CHECKDB:
  DBCC CHECKDB ('YourDatabaseName', REPAIR_REBUILD);
  • If REPAIR_REBUILD doesn’t resolve it, escalate cautiously to:
  DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);
  • Return the database to multi-user mode:
  ALTER DATABASE YourDatabaseName SET MULTI_USER;

Step 4: Rebuild Fragmented Indexes

  • Once integrity is restored, rebuild affected indexes to clear residual fragmentation metadata:
  ALTER INDEX ALL ON YourTableName REBUILD WITH (ONLINE = ON);
  • Confirm no further allocation-level warnings appear in subsequent CHECKDB runs.

Alternative or Verification Steps

  • Re-run DBCC SHOWCONTIG or sys.dm_db_index_physical_stats against the previously affected table/index to confirm the Extent Scan Fragmentation percentage now reports cleanly without Error 7952.
  • If corruption persists after repair attempts, restore the affected database from the most recent verified backup (RESTORE DATABASE ... WITH CHECKSUM) rather than continuing with REPAIR_ALLOW_DATA_LOSS, since this guarantees full data consistency.

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

Troubleshooting Guide: SQL Server Error 7949 (DBCC Scan Density Reporting Anomaly)

Why This Error Happens

Error 7949 typically surfaces during DBCC SHOWCONTIG or DBCC CHECKDB operations when SQL Server 2025 calculates fragmentation statistics and encounters a mismatch between the “Best Count” and “Actual Count” of extents/pages. This is usually caused by underlying index fragmentation, a corrupted allocation map (IAM/GAM/SGAM pages), or an interrupted maintenance operation that left page linkage inconsistent. In most cases, this message is informational rather than fatal, but a persistently low scan density ratio (far below 100%) signals genuine physical disk fragmentation or metadata corruption requiring remediation.

Step-by-Step Resolution Guide

Step 1: Validate Database Integrity First

  • Open SQL Server Management Studio (SSMS) or sqlcmd and run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output for allocation errors alongside the 7949 message — if CHECKDB reports consistency errors, prioritize fixing those before addressing fragmentation.
  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for correlating timestamps.

Step 2: Rebuild or Reorganize Fragmented Indexes

  • Identify fragmentation levels using SELECT * FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED');
  • For indexes with fragmentation > 30%, run ALTER INDEX ALL ON [TableName] REBUILD WITH (ONLINE = ON, SORT_IN_TEMPDB = ON);
  • For fragmentation between 10-30%, use ALTER INDEX ALL ON [TableName] REORGANIZE; instead, as it’s less resource-intensive.
  • Ensure sufficient free space in the database and tempdb before rebuilding (at least 1.5x the size of the largest index).

Step 3: Check Disk and File-Level Health

  • Verify the underlying storage volume isn’t experiencing latency or corruption using Windows Admin Center or Perfmon (Physical Disk > Avg. Disk sec/Read & Write).
  • Confirm NTFS allocation unit size is set to 64 KB for SQL data/log volumes (recommended for SQL Server 2025 workloads).
  • Run chkdsk D: /f /r (replace D: with your data drive letter) during a maintenance window if disk-level corruption is suspected.

Step 4: Update SQL Server Cumulative Update

  • Navigate to Microsoft Update Catalog and confirm you’re running the latest Cumulative Update (CU) for SQL Server 2025, as early releases had a known telemetry bug misreporting scan density in Error 7949.
  • Apply the update via Setup.exe or SQL Server Installation Center, then restart the SQL Server (MSSQLSERVER) service from services.msc.

Alternative or Verification Steps

  • Re-run DBCC SHOWCONTIG or query sys.dm_db_index_physical_stats after rebuilding indexes to confirm the Best Count:Actual Count ratio approaches 1:1 (100% scan density).
  • If the error persists after rebuilding and patching, restore the database from a known-good backup to a test instance and compare DBCC CHECKDB results to isolate whether the issue is data corruption or a reporting/telemetry glitch in SQL Server 2025.

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

Troubleshooting Guide: SQL Server Error 7950 — Logical Scan Fragmentation Reporting Issue

Why This Error Happens

Error 7950 typically surfaces during execution of DBCC SHOWCONTIG or related index diagnostic commands when the output formatting string (Logical Scan Fragmentation ..................: %4.2f%ls) fails to resolve correctly, usually due to a corrupted system catalog view, a damaged index allocation map (IAM), or incompatible locale/resource DLL files. This can also occur if the SQL Server resource database (mssqlsystemresource.mdf) is mismatched or corrupted after a patch/upgrade on Windows Server 2025, causing the message formatting engine to throw a malformed string error. In some cases, underlying disk-level corruption on the pages being scanned triggers this when DBCC cannot properly calculate fragmentation percentages.

Step-by-Step Resolution Guide

Step 1: Verify SQL Server Resource Database Integrity

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run SELECT SERVERPROPERTY('ResourceVersion'), SERVERPROPERTY('ResourceLastUpdateDateTime'); to confirm resource DB version matches your installed build.
  • Compare the version against the official build listed in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\ folder properties.

Step 2: Run DBCC CHECKDB to Rule Out Corruption

  • Execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review output for allocation or consistency errors tied to the index pages being scanned.
  • If corruption is found, run DBCC CHECKDB ('YourDatabaseName') WITH REPAIR_REBUILD; while the instance is in single-user mode.

Step 3: Rebuild Fragmented Indexes Instead of Relying on Legacy DBCC Output

  • Replace legacy DBCC SHOWCONTIG calls with sys.dm_db_index_physical_stats, which is fully supported in SQL Server 2025.
  • Run: SELECT * FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED');
  • Rebuild affected indexes using ALTER INDEX ALL ON YourTable REBUILD WITH (ONLINE = ON);

Step 4: Reinstall or Repair SQL Server Native Client Components

  • Go to Control Panel > Programs > Programs and Features on Windows Server 2025.
  • Select Microsoft SQL Server 2025, click Change, then choose Repair.
  • This restores corrupted resource DLLs and message formatting libraries tied to DBCC output strings.

Alternative or Verification Steps

  • Re-run sys.dm_db_index_physical_stats after the rebuild and confirm avg_fragmentation_in_percent returns a clean numeric value instead of triggering error 7950.
  • If the error persists, restore the mssqlsystemresource.mdf and .ldf files from a known-good backup or installation media, then restart the SQL Server service via services.msc.

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

Why This Error Happens

Error 7947 typically surfaces during DBCC CHECKDB, CHECKTABLE, or CHECKALLOC operations when SQL Server 2025 encounters internal inconsistencies while traversing extent and page allocation structures. This is often triggered by underlying disk-level corruption, incomplete I/O operations (torn pages), or insufficient tempdb space needed to complete the consistency check report. In some cases, outdated storage drivers on Windows Server 2025 or Windows 11 can cause intermittent write failures that corrupt the allocation bitmaps SQL Server relies on to calculate extent switches.

Step-by-Step Resolution Guide

Step 1: Verify Database and Disk Integrity

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; in SQL Server Management Studio (SSMS) to capture the full corruption report.
  • Check the Windows Event Viewer (Application and System logs) for disk-related warnings (Event ID 51 or 153) that indicate storage subsystem failures.
  • Run chkdsk /f on the volume hosting your .mdf and .ldf files via an elevated Command Prompt.

Step 2: Allocate Sufficient Tempdb Space

  • Navigate to SSMS > Databases > tempdb > Properties > Files.
  • Increase the initial size of tempdb data files (e.g., set to 5120 MB) since DBCC operations use tempdb heavily to store internal worktables for extent tracking.
  • Ensure the tempdb file path (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\) has at least 20% free disk space.

Step 3: Update Storage and Filter Drivers

  • Open Device Manager on Windows Server 2025 / Windows 11 and update drivers for Storage Controllers and Disk Drives.
  • Verify no third-party antivirus or backup agents (mini-filter drivers) are locking the .mdf files during the DBCC scan by temporarily disabling them.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc to clear any stale file handles.

Step 4: Repair or Restore from Backup

  • If corruption is confirmed via the Step 1 output, run DBCC CHECKDB ('YourDatabaseName', REPAIR_REBUILD); for data pages without data loss.
  • If the corruption is severe (e.g., system tables affected), restore the database from the last known good full backup using RESTORE DATABASE... WITH RECOVERY.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB immediately after the repair; a clean run with 0 allocation errors confirms the fix was successful.
  • If the error persists despite a healthy disk, failover to a secondary replica (if using Always On Availability Groups) and rebuild the primary database from scratch to rule out residual metadata corruption.

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

Troubleshooting Guide: SQL Server Error 7948 (“Avg. Pages per Extent”)

Why This Error Happens

Error 7948 is generated by DBCC CHECKDB (or DBCC CHECKALLOC) as part of its informational output regarding space allocation, specifically reporting the “Avg. Pages per Extent” ratio for a database. While the message itself is typically just a statistical output rather than a critical failure, it is often reported alongside corruption warnings when the underlying extent allocation bitmaps (GAM, SGAM, or IAM pages) are damaged due to improper shutdowns or storage-level I/O failures. In Microsoft SQL Server 2025 running on Windows Server 2025/Windows 11, this usually surfaces when the storage subsystem has a mismatch between physical disk sector sizes and the SQL Server page allocation unit, or when a checkpoint process was interrupted by a hardware failure.

Step-by-Step Resolution Guide

Step 1: Isolate the Database and Check Immediate Integrity

  • Open SQL Server Management Studio (SSMS) and connect to the Windows Server 2025 instance.
  • Run the following command to check the full scope of the error without the server attempting repairs yet:
  DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Look for accompanying error codes (e.g., Error 8909 or 8928) that usually trigger the 7948 statistical readout; isolate if this is a standalone stat or a symptom of a larger corruption event.

Step 2: Verify Windows Server Storage and Disk Health

  • Navigate to Server Manager > File and Storage Services > Disks to check the physical health status of the volume hosting the .mdf and .ldf files.
  • Open an elevated PowerShell terminal and run a check on the specific volume’s file system integrity:
  Repair-Volume -DriveLetter D -Scan
  • Confirm that the disk sector size configuration in Windows Server 2025 matches the SQL Server 2025 instance configuration (4K alignment is required for 2025 builds).

Step 3: Execute Targeted Repair (If Corruption is Confirmed)

  • If Step 1 confirmed allocation errors beyond the standard stat message, take the database into single-user mode via SSMS or a query window:
  ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run the repair command specific to allocation errors (use with caution as this may result in data loss):
  DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);
  • Revert the database back to multi-user access once the repair job completes:
  ALTER DATABASE YourDatabaseName SET MULTI_USER;

Step 4: Restore From Backup (Preferred Method)

  • Navigate to your backup directory (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Backup\) to locate the latest clean .bak file.
  • Perform a standard restore operation to overwrite the corrupted extents entirely, ensuring minimal data loss compared to the REPAIR_ALLOW_DATA_LOSS flag.

Alternative or Verification Steps

  • Verify the Fix: Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS; and confirm the command returns “0 allocation errors and 0 consistency errors.”
  • Alternative Solution: If the error persists after a repair, detach the database, move the physical files to a different, verified-healthy disk volume on the Windows Server 2025 host, and re-attach it via CREATE DATABASE...FOR ATTACH.

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

Why This Error Happens

Error 7945 typically surfaces during a DBCC CHECKDB or DBCC CHECKTABLE operation when SQL Server encounters an internal processing conflict while generating the consistency report, often due to insufficient tempdb space to store the internal snapshot used for the scan. This can also occur if the database has underlying allocation page corruption that interrupts the scan before the “Pages Scanned” count can be finalized and returned. In Windows Server 2025 / Windows 11 environments, this is frequently exacerbated by antivirus or EDR software locking data files mid-scan, causing the engine to lose its internal transaction consistency snapshot.

Step-by-Step Resolution Guide

Step 1: Verify and Expand TempDB Capacity

  • Open SQL Server Management Studio (SSMS) and connect to the instance reporting the error.
  • Run EXEC sp_helpdb 'tempdb'; to check current size versus autogrowth settings.
  • If space is constrained, manually expand the file using: ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, SIZE = 5120MB);
  • Ensure the drive hosting tempdb (usually C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA) has at least 20% free space.

Step 2: Exclude SQL Server Directories from Antivirus/Defender Scanning

  • Navigate to Windows Security > Virus & threat protection > Manage settings > Exclusions.
  • Add exclusions for the SQL Server data, log, and backup directories (e.g., D:\SQLData\, D:\SQLLogs\).
  • Exclude the sqlservr.exe process explicitly to prevent file-locking during the internal consistency check.
  • Restart the SQL Server service via services.msc to apply the exclusion cleanly.

Step 3: Run DBCC CHECKDB with Extended Logging

  • Open a new query window and run: DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS, EXTENDED_LOGICAL_CHECKS;
  • Capture the full output, paying attention to any error codes preceding the “Pages Scanned” line (such as 8909 or 8928), as these indicate the specific corrupted page.
  • If physical corruption is confirmed, restore the affected database from the last known good backup rather than attempting a repair that could cause data loss.

Step 4: Check Windows Event Viewer for Disk I/O Errors

  • Open Event Viewer > Windows Logs > System and filter for Event ID 7 or 129 (related to disk subsystem).
  • Cross-reference timestamps with the SQL Server error log (ERRORLOG file) to confirm if a hardware-level fault triggered the 7945 error during the scan.
  • If disk errors are present, run chkdsk D: /f /r on the affected volume during a maintenance window.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB immediately after applying the fixes; a clean run with a full “Pages Scanned” count and zero allocation errors confirms resolution.
  • If the error persists, restore the database to a secondary/test server from a recent backup and run the integrity check there to isolate whether the issue is hardware-specific to the original host.

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

Why This Error Happens

Error 7946 is generated by the SQL Server Database Consistency Checker (DBCC) and typically surfaces while DBCC CHECKDB, CHECKALLOC, or CHECKFILEGROUP is scanning extents to validate database integrity. The root cause is usually that the internal database snapshot SQL Server creates to run the consistency check cannot be sustained—either because the volume hosting the data files has insufficient free space, the service account lacks permission to create the hidden snapshot sparse file, or underlying page/extent corruption is preventing the scan from completing cleanly. In Windows Server 2025 environments, this is also frequently triggered by antivirus or Windows Defender real-time scanning locking the sparse file used for the snapshot.

Step-by-Step Resolution Guide

Step 1: Verify Disk Space on the Volume Hosting the Database

  • Check the drive containing your .mdf/.ndf files has at least 10-15% free space, since the internal snapshot requires room equal to the pages modified during the check.
  • Run Get-PSDrive in PowerShell or check Disk Management on Windows Server 2025 to confirm available space.
  • Move or expand the disk if space is below the required threshold.

Step 2: Confirm Service Account Permissions

  • Open SQL Server Configuration Manager and verify the SQL Server service account has full control on the data directory (typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA).
  • Right-click the folder, go to Properties > Security, and ensure the SQL Server service account (e.g., NT Service\MSSQLSERVER) has Read/Write/Modify permissions.
  • Restart the SQL Server service after applying permission changes.

Step 3: Exclude SQL Server Directories from Antivirus/Defender Scanning

  • Add exclusions in Windows Defender (or third-party AV) for the SQL Server data, log, and backup directories.
  • Use PowerShell: Add-MpPreference -ExclusionPath "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA"
  • Re-run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to see if the snapshot now completes without interruption.

Step 4: Run DBCC CHECKDB with a Manual Physical-Only Scan

  • If the full logical check keeps failing at the extent scan phase, isolate the issue by running a lighter check first:
  • Execute DBCC CHECKDB('YourDatabaseName') WITH PHYSICAL_ONLY, NO_INFOMSGS;
  • This identifies whether the problem is torn pages/corruption versus a transient snapshot creation issue.

Step 5: Repair or Restore if Corruption Is Confirmed

  • If physical corruption is found, take a current backup immediately, then run DBCC CHECKDB('YourDatabaseName') WITH REPAIR_ALLOW_DATA_LOSS; only as a last resort in single-user mode.
  • Prefer restoring from the last known good backup if data loss from repair is unacceptable.

Alternative or Verification Steps

  • After applying fixes, re-run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm it completes with “0 allocation errors and 0 consistency errors” and no Error 7946 in the output or SQL Server error log.
  • If the error persists, check the SQL Server Error Log (ERRORLOG in the LOG folder) and Windows Event Viewer (Application log) for correlating disk I/O or VSS snapshot failures, which may indicate a deeper storage subsystem issue requiring a hardware/storage driver check.

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

Troubleshooting Guide: SQL Server Error 7943

Why This Error Happens

Error 7943 occurs when SQL Server’s DBCC CHECKDB (or related consistency checking operations) detects a structural inconsistency in a database page, specifically a corrupted “Getting Data” record within a table or index structure. This typically stems from underlying storage subsystem issues such as disk I/O failures, faulty RAID controllers, or improper shutdowns that interrupted write operations before they fully committed to disk. Additionally, corruption can be introduced by failing hardware (SSD/HDD degradation), memory errors (bad RAM) during write operations, or filesystem-level issues on Windows Server 2025/Windows 11 that silently damage database file integrity.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; in SQL Server Management Studio (SSMS) to get a full consistency report.
  • Note the exact table name, object ID, and index ID referenced in the error message (e.g., Table: ‘dbo.Orders’, index ID: 1).
  • Check the SQL Server error log (default path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related I/O or hardware warnings around the same timestamp.

Step 2: Check and Isolate Hardware/Storage Issues

  • Open Windows Event Viewer (eventvwr.msc) and review the System log under Windows Logs for Disk, ntfs, or storport errors.
  • Run chkdsk C: /f /r (replace with the correct drive letter hosting your .mdf/.ldf files) via an elevated Command Prompt, then reboot to allow Windows to scan and repair the volume.
  • If using virtualized storage (Hyper-V/Azure), verify the underlying host storage health and confirm no recent unexpected VM shutdowns occurred.

Step 3: Restore From a Clean Backup (Preferred Method)

  • Take the affected database offline: ALTER DATABASE YourDatabaseName SET OFFLINE WITH ROLLBACK IMMEDIATE;
  • Restore the most recent clean full backup along with subsequent transaction log backups using SSMS or RESTORE DATABASE YourDatabaseName FROM DISK = 'BackupPath.bak' WITH REPLACE, RECOVERY;
  • This avoids data loss, unlike repair commands that may discard corrupted rows.

Step 4: Run Repair as a Last Resort (If No Backup Exists)

  • Set the database to single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Execute DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS; — understand this may delete corrupted rows permanently.
  • Return the database to multi-user mode afterward: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Alternative or Verification Steps

  • After applying a fix, re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm it returns zero allocation and consistency errors.
  • As an alternative, if corruption recurs frequently, consider rebuilding the specific nonclustered index flagged in the error (ALTER INDEX ALL ON dbo.TableName REBUILD;) and schedule regular DBCC CHECKDB jobs alongside hardware diagnostics to catch future issues early.

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

Troubleshooting Guide: SQL Server Error 7944 — “%ls level scan performed”

Why This Error Happens

Error 7944 is typically an informational or diagnostic message generated by DBCC CHECKDB (or related consistency check commands) indicating the depth of scan performed against a database object, such as a physical-only, data-purity, or extended logical scan. This message surfaces more frequently when underlying data pages are corrupted, when the database has outdated statistics causing the engine to fall back to a different scan level, or when consistency checks are run with non-default parameters (e.g., PHYSICAL_ONLY or NOINDEX). In most cases, this is not a standalone failure but a symptom pointing to deeper storage subsystem issues, disk I/O errors, or incomplete index metadata on Windows Server 2025 / Windows 11 hosts.

Step-by-Step Resolution Guide

Step 1: Confirm the Context of the Message

  • Open SQL Server Error Logs via SQL Server Management Studio (SSMS) > Management > SQL Server Logs.
  • Search for Error 7944 and note the accompanying database name, object ID, and scan type referenced in the %ls placeholder.
  • Cross-reference the timestamp with any recent DBCC CHECKDB, CHECKTABLE, or CHECKALLOC jobs in the SQL Server Agent Job History.

Step 2: Run a Full Diagnostic Scan

  • Open a new query window in SSMS and execute a complete integrity check:
  • DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • If the database is large, run a physical-only scan first to rule out hardware-level corruption:
  • DBCC CHECKDB ('YourDatabaseName') WITH PHYSICAL_ONLY;
  • Review the output for accompanying error codes (823, 824, or 825) that often travel alongside 7944 and point to disk-level problems.

Step 3: Validate Storage and File System Health

  • On Windows Server 2025 / Windows 11, open Command Prompt as Administrator and run chkdsk C: /f /r (replace C: with the drive hosting your .mdf/.ndf files) to rule out file system corruption.
  • Check Event Viewer under Windows Logs > System for any Disk, ntfs, or storage controller warnings coinciding with the SQL error timestamp.
  • Verify that antivirus or backup software is not locking or scanning the SQL Server data directory (typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\), and add exclusions if necessary.

Step 4: Rebuild Indexes and Update Statistics

  • If CHECKDB reports no critical corruption but Error 7944 persists, rebuild affected indexes to clear stale metadata:
  • ALTER INDEX ALL ON YourTableName REBUILD;
  • Update statistics to ensure the query optimizer and scan engine have current data distribution information:
  • UPDATE STATISTICS YourTableName WITH FULLSCAN;

Step 5: Apply Latest Cumulative Update

  • Confirm your SQL Server 2025 build number via SELECT @@VERSION;.
  • Visit the Microsoft Update Catalog and install the latest Cumulative Update (CU) for SQL Server 2025, as scan-level messaging bugs are frequently patched in CU releases.
  • Restart the SQL Server service via services.msc or NET STOP MSSQLSERVER && NET START MSSQLSERVER after installation.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB with NO_INFOMSGS immediately after completing the steps above; a clean result with no Error 7944 recurrence confirms resolution.
  • If the error persists, restore the affected database from the most recent verified clean backup to a test instance and compare DBCC results to isolate whether the issue is data-specific or environment-specific.

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

Why This Error Happens

SQL Server Error 7940 occurs when an attempt is made to create a database snapshot against one of the system databases (master, model, msdb, or tempdb). The SQL Server Database Engine explicitly blocks snapshot creation on these databases because they are tightly coupled to instance-level operations, recovery, and startup sequences. This restriction exists by design in SQL Server 2025 (as in all prior versions) and is not a bug, configuration error, or corruption issue — it is a hard-coded engine limitation enforced regardless of permissions or server edition.

Step-by-Step Resolution Guide

Step 1: Identify the Script or Job Triggering the Snapshot

  • Review the T-SQL script, SQL Agent Job, or third-party backup/HA tool (e.g., Always On health checks, custom DR scripts) that issued the CREATE DATABASE ... AS SNAPSHOT OF command.
  • Check SQL Server Error Logs (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for the exact statement and timestamp tied to Error 7940.
  • Confirm whether the target database name in the failing command is master, model, msdb, or tempdb.

Step 2: Remove System Databases from the Snapshot Target List

  • Edit the automation script or maintenance plan to explicitly exclude system databases from the snapshot loop.
  • If using a PowerShell or dbatools-based job, filter with a condition such as:
  • WHERE name NOT IN ('master','model','msdb','tempdb')
  • If using SQL Server Management Studio (SSMS) Maintenance Plans, open the plan in SSMS → Management → Maintenance Plans, and deselect system databases in the “Databases” selection dialog.

Step 3: Redirect Snapshot Needs to User Databases or Alternative Backup Methods

  • For master and msdb, rely on native full backups instead of snapshots:
  • BACKUP DATABASE master TO DISK = 'E:\Backups\master.bak';
  • For tempdb, snapshots are irrelevant since it is recreated on every service restart — no backup is needed.
  • For model, if you need point-in-time recovery of configuration changes, script out the database settings instead of snapshotting it.

Step 4: Validate Automation Logic in SQL Agent Jobs

  • Open SQL Server Agent → Jobs in SSMS, locate the job step that failed.
  • Confirm the job step’s T-SQL or PowerShell logic dynamically pulls database names from sys.databases and properly filters database_id > 4 (which excludes all four system databases).

Alternative or Verification Steps

  • Re-run the job or script after excluding system databases, and confirm no Error 7940 entries appear in the SQL Server Error Log or Windows Event Viewer (Applications and Services Logs → MSSQLSERVER) for Event ID 7940.
  • As a quick sanity check, manually test snapshot creation on a user database (e.g., CREATE DATABASE TestDB_Snap ON (NAME = TestDB, FILENAME = 'E:\Snap\TestDB_Snap.ss') AS SNAPSHOT OF TestDB;) to confirm the snapshot feature itself is functioning correctly outside of system databases.

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

Why This Error Happens

Error 7941 occurs when SQL Server’s DBCC CHECKDB detects structural inconsistencies in the internal linkage of a table object, often due to corrupted index pages, mismatched row offsets, or interrupted I/O operations during a write. This frequently results from underlying disk corruption, improper server shutdowns, or faulty storage hardware/drivers on Windows Server 2025. It can also surface after a failed database restore or when antivirus software locks MDF/LDF files mid-transaction.

Step-by-Step Resolution Guide

Step 1: Run a Full Diagnostic Check

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to identify the exact object ID and page causing the error.
  • Review the Windows Event Viewer (Application Log) for correlating Disk or NTFS errors around the same timestamp.

Step 2: Isolate and Repair the Corrupted Object

  • Place the database in single-user mode using ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;.
  • Run the repair command: DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS); (Note: Only use this if a clean restore isn’t immediately available, as it may delete corrupted rows to maintain structural integrity).
  • Set the database back to multi-user mode: ALTER DATABASE YourDatabaseName SET MULTI_USER;.

Step 3: Restore from a Clean Backup

  • Navigate to your backup directory (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Backup\).
  • Restore the most recent full backup taken before the corruption occurred using RESTORE DATABASE YourDatabaseName FROM DISK = 'PathToYourBackup.bak' WITH REPLACE;.
  • Apply any available transaction log backups to minimize data loss.

Step 4: Check Underlying Hardware and Drivers

  • Open Device Manager on Windows Server 2025 and update storage controller drivers to the latest vendor-certified version.
  • Run chkdsk C: /f /r via an elevated Command Prompt to scan for and repair physical disk sector errors.

Alternative or Verification Steps

  • After repair/restore, re-run DBCC CHECKDB on the database; a clean result with zero allocation or consistency errors confirms the fix was successful.
  • If corruption recurs immediately after repair, consider migrating the database files to a different physical disk/volume and updating storage drivers, as this typically points to a failing hardware component rather than a software-level issue.

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

Troubleshooting Guide: DBCC Error 7942 in SQL Server 2025

Why This Error Happens

Error 7942 is an informational message generated by DBCC CHECKDB (or related DBCC commands) indicating that the engine is actively scanning a specific table during a consistency check operation. This typically surfaces alongside performance degradation when the underlying table has significant logical fragmentation, oversized LOB/BLOB data, or when the scan is competing for I/O resources with other active transactions. In most cases, the root cause isn’t corruption itself, but rather insufficient tempdb space, disk I/O bottlenecks, or memory pressure preventing the scan from completing efficiently on Windows Server 2025 environments.

Step-by-Step Resolution Guide

Step 1: Verify Tempdb Configuration and Space Allocation

  • Navigate to SQL Server Management Studio (SSMS) > Databases > tempdb > Properties > Files.
  • Ensure tempdb data files are pre-sized appropriately (minimum 10% of user database size for large checks) and are not set to small, incremental auto-growth values.
  • Run DBCC SQLPERF(logspace) to confirm tempdb log space isn’t nearing capacity during the scan.

Step 2: Isolate I/O Contention on the Physical Disk

  • Open Performance Monitor (PerfMon) on Windows Server 2025 and add the counter PhysDisk(*)\Avg. Disk sec/Read.
  • If latency exceeds 20ms consistently during the DBCC scan, the physical storage layer is the bottleneck, not the SQL engine.
  • Move the table’s filegroup to a separate high-speed NVMe volume if latency is confirmed.

Step 3: Run DBCC CHECKDB with the Correct Scope

  • Instead of running a full database check, isolate the specific table referenced in the error message using the following T-SQL syntax:
  • DBCC CHECKTABLE ('YourTableName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • This prevents the message from generating noise in the error log while you check for underlying structural issues specific to that object.

Step 4: Update SQL Server 2025 Cumulative Updates

  • Check SQL Server Configuration Manager to verify the current build number against the latest Cumulative Update (CU) released by Microsoft for SQL Server 2025.
  • Legacy DBCC scanning algorithms in early 2025 builds have been optimized in recent patches to reduce false-positive informational logging.
  • Download and apply the update via Microsoft Update Catalog or the integrated SQL Server Update Assistant.

Alternative or Verification Steps

  • Verify the fix by checking the SQL Server Error Log (Management > SQL Server Logs in SSMS) to confirm the DBCC scan completes with a “0 allocation errors and 0 consistency errors” result following the Step 3 execution.
  • If the message persists with high latency, as an alternative, schedule the DBCC CHECKDB job during off-peak hours using SQL Server Agent to eliminate resource contention with live user transactions.

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

Troubleshooting Guide: SQL Server Error 7938 — “Table error: object ID %d”

Why This Error Happens

Error 7938 is raised by DBCC CHECKDB when it detects that the allocation structures (such as IAM pages or PFS/GAM/SGAM pages) associated with a table object do not match the actual extent or page allocations on disk. This typically occurs due to physical database corruption caused by faulty storage hardware, improper shutdowns, disk controller firmware bugs, or antivirus/backup software locking data files mid-write. It can also surface after a failed storage migration or when the underlying NTFS/ReFS volume on Windows Server 2025 experiences bad sectors or silent data corruption that SQL Server’s checksum validation later detects.

Step-by-Step Resolution Guide

Step 1: Confirm and Isolate the Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOREPAIR, ALL_ERRORMSGS, EXTENDED_LOGICAL_CHECKS; from SQL Server Management Studio to capture the full scope of the corruption.
  • Note the specific object ID reported in the error and cross-reference it using SELECT OBJECT_NAME(object_id) FROM sys.objects WHERE object_id = <ID>;.
  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related I/O or disk warnings around the same timestamp.

Step 2: Check Hardware and Windows Event Logs

  • Open Windows Event Viewer (eventvwr.msc) and inspect the System log for Disk, NTFS, or Storport errors on Windows Server 2025.
  • Run chkdsk D: /f /r (replace D: with the volume hosting your .mdf/.ldf files) during a maintenance window to repair file system-level issues.
  • Verify disk health using Get-PhysicalDisk | Get-StorageReliabilityCounter in PowerShell to rule out failing hardware.

Step 3: Restore From a Known Good Backup (Preferred Fix)

  • Take a tail-log backup if the database is still accessible: BACKUP LOG YourDatabaseName TO DISK = 'E:\Backups\TailLog.trn';
  • Restore the last clean full backup plus subsequent log backups to a point before the corruption occurred, using RESTORE DATABASE with WITH NORECOVERY followed by WITH RECOVERY on the final log.
  • Validate restored database integrity immediately with DBCC CHECKDB before bringing it back online for production use.

Step 4: Use Repair Options Only as a Last Resort

  • If no clean backup exists, set the database to single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS); understanding this may delete corrupted rows/pages to restore structural consistency.
  • Set the database back to multi-user mode: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH ALL_ERRORMSGS, NO_INFOMSGS; after remediation to confirm zero allocation or consistency errors remain.
  • If corruption recurs on the same object or volume, migrate the database files to new storage and engage your hardware vendor’s diagnostics (e.g., Storage Spaces Direct health reports) to rule out failing disks.

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

Troubleshooting Guide: SQL Server Error 7939 — “Cannot detach database because it does not exist”

Why This Error Happens

Error 7939 occurs when SQL Server’s metadata in sys.databases does not contain an entry matching the database name supplied in the sp_detach_db command, typically due to a case-sensitivity mismatch, a typo, or trailing whitespace in the database name. This can also happen if the database was already dropped, detached by another session, or if you are connected to the wrong SQL Server instance (common in multi-instance installations on Windows Server 2025). Additionally, if the database exists in a different context (such as a contained availability group or a different collation catalog), SQL Server will not resolve the name correctly and will throw this error.

Step-by-Step Resolution Guide

Step 1: Verify the Exact Database Name and Instance

  • Run SELECT name, state_desc, database_id FROM sys.databases; to get the exact, case-accurate name of the database.
  • Confirm you are connected to the correct instance using SELECT @@SERVERNAME; — on Windows Server 2025, check SQL Server Configuration Manager if multiple instances are installed.
  • Copy the exact name from the query output rather than retyping it manually to avoid hidden whitespace or encoding issues.

Step 2: Check for Prior Detachment or Drop Operations

  • Review the SQL Server Error Log (via EXEC sp_readerrorlog; or SSMS > Management > SQL Server Logs) for recent DROP DATABASE or sp_detach_db entries.
  • Check Windows Event Viewer under Applications and Services Logs > Microsoft > Windows > SQLServer for related Event ID 7939 timestamps to correlate with other administrative activity.
  • If another DBA or automated job (e.g., SQL Agent job, PowerShell script, or Always On failover) already detached the database, there’s no further action needed.

Step 3: Re-run the Detach Command with Correct Syntax

  • Use the bracketed, exact name retrieved in Step 1:
  EXEC sp_detach_db @dbname = N'[ExactDatabaseName]', @skipchecks = 'false';
  • Ensure there are no leading/trailing spaces by wrapping the name in QUOTENAME() if scripting dynamically.
  • If using SSMS GUI, right-click Databases, refresh the object explorer (F5), then retry the Detach option from the context menu.

Step 4: Refresh Metadata Cache and Object Explorer

  • In SSMS, right-click the Databases node and select Refresh to force a metadata reload, since stale cached views can display databases that no longer exist server-side.
  • If using a script-based connection, disconnect and reconnect the session to clear any cached sys.databases snapshot held by the query window.

Alternative or Verification Steps

  • Verify success by re-querying SELECT name FROM sys.databases WHERE name = 'YourDatabaseName'; — it should return zero rows after a successful detach.
  • If the database still appears “stuck,” restart the SQL Server service via services.msc on Windows Server 2025/Windows 11 (or use Restart-Service MSSQLSERVER in PowerShell) to clear any orphaned metadata cache, then repeat Step 1.

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

Troubleshooting Guide: SQL Server Error 7936 (FILESTREAM Directory ID Mismatch)

Why This Error Happens

Error 7936 occurs when the FILESTREAM directory ID stored in the database metadata does not match the actual directory structure on the filesystem, indicating catalog corruption between SQL Server’s internal tables and the FILESTREAM filegroup container. This is typically caused by an unexpected shutdown during a FILESTREAM write operation, manual tampering with files inside the FILESTREAM data container, or a failed/interrupted restore operation. Because FILESTREAM relies on NTFS to store BLOB data while SQL Server manages the transactional consistency, any desynchronization between the two triggers this integrity check failure.

Step-by-Step Resolution Guide

Step 1: Run a Diagnostic Check with DBCC CHECKDB

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Execute DBCC CHECKDB ('YourDatabaseName') WITH ALL_ERRORMSGS, NO_INFOMSGS; to confirm the scope of the corruption.
  • Check the Windows Event Viewer (Windows Logs > Application) for correlating disk I/O errors (Event ID 7 or 153) that might indicate underlying storage issues rather than pure logical corruption.

Step 2: Isolate and Restore from a Clean Backup

  • Take the database offline temporarily: ALTER DATABASE YourDatabaseName SET OFFLINE;
  • Locate your last known good full backup (ideally one taken before the corruption event).
  • Restore the database to a new instance name first to verify the backup’s integrity before overwriting production data:
    RESTORE DATABASE YourDatabaseName_Test FROM DISK = 'E:\Backups\YourDatabaseName.bak' WITH REPLACE;

Step 3: Repair the FILESTREAM Filegroup (If No Backup is Available)

  • If a backup is unavailable, attempt DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS); as a last resort—note this may unlink the orphaned FILESTREAM BLOB.
  • Navigate to the physical FILESTREAM container path (e.g., D:\SQLData\FileStreamData\) and verify the $FSLOG and GUID-named directories haven’t been manually altered or deleted by antivirus/backup software.
  • Ensure no third-party antivirus or indexing service is scanning or locking files within the FILESTREAM directory, as this is a common cause of ID mismatches on Windows Server 2025.

Step 4: Validate Permissions and Service Accounts

  • Confirm the SQL Server service account has full control over the FILESTREAM share via Computer Management > System Tools > Shared Folders.
  • Check that the “SQL Server FILESTREAM share” feature is still enabled in SQL Server Configuration Manager under the instance’s Properties.

Alternative or Verification Steps

  • Verification: Re-run DBCC CHECKDB on the repaired or restored database. If the output returns “0 allocation errors and 0 consistency errors,” the FILESTREAM catalog is synced correctly.
  • Alternative: If corruption persists, export the remaining accessible FILESTREAM BLOBs using OPENROWSET(BULK...) to a flat file share, then rebuild the table schema and re-import the data to bypass the corrupted directory ID entirely.

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

Troubleshooting Guide: Error 7937 – Columnstore Index Missing Column Segments

Why This Error Happens

Error 7937 occurs when SQL Server detects that one or more column segments belonging to a columnstore index are missing from the underlying storage structure, typically due to physical page corruption, incomplete transaction rollbacks, or storage-level I/O failures. This can also happen if the database was restored from an inconsistent backup, if a disk/SAN-level fault silently damaged pages, or if the server experienced an unexpected shutdown during a columnstore maintenance operation (such as a tuple-mover or index rebuild). Since columnstore indexes store data in compressed segments mapped internally via the system metadata, any mismatch between the metadata and the actual segment files triggers this consistency error.

Step-by-Step Resolution Guide

Step 1: Run a Full Consistency Check

  • Open SQL Server Management Studio (SSMS) or use sqlcmd on Windows Server 2025 / Windows 11.
  • Execute: DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output to confirm the specific object ID, index ID, and partition where the missing segment was detected.

Step 2: Isolate the Affected Table and Index

  • Query sys.column_store_segments and sys.partitions to cross-reference the damaged object ID reported by DBCC.
  • Example: SELECT * FROM sys.column_store_segments WHERE partition_id = <PartitionID>;
  • Confirm whether the issue is isolated to one partition or spans the entire columnstore index.

Step 3: Repair Using DBCC CHECKDB with Repair Option

  • If backups are unavailable or outdated, run: DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Note: This option may delete the corrupted segment or rebuild the index structure, potentially causing data loss in the affected rows.
  • Always run this in SINGLE_USER mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

Step 4: Restore From a Known-Good Backup (Preferred Method)

  • If a valid backup exists, restore the database or the specific filegroup containing the columnstore index.
  • Use: RESTORE DATABASE YourDatabaseName FROM DISK = 'E:\Backups\YourDB_Full.bak' WITH REPLACE, RECOVERY;
  • This avoids forced repairs and preserves data integrity far better than REPAIRALLOWDATA_LOSS.

Step 5: Rebuild the Columnstore Index

  • Once the database is stable, rebuild the affected index to regenerate segment metadata: ALTER INDEX YourColumnstoreIndexName ON YourTableName REBUILD;
  • Set the database back to multi-user mode: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Alternative or Verification Steps

  • Re-run DBCC CHECKDB after remediation to confirm zero errors are reported and segment counts match expected values in sys.column_store_segments.
  • If corruption recurs frequently, run Windows Server 2025 hardware diagnostics (Event Viewer → System logs, and chkdsk /f on the underlying volume) to rule out disk-level faults causing repeated columnstore corruption.

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

Troubleshooting Guide: SQL Server Error 7934 – DBCC CHECK Fails on Secondary Replica

Why This Error Happens

Error 7934 occurs because DBCC CHECKDB attempts to create an internal database snapshot to perform consistency checks on a secondary replica, but this snapshot creation failed or was bypassed due to the explicit use of the WITH TABLOCK option. Since secondary replicas in an Always On Availability Group are read-only, SQL Server cannot acquire the exclusive lock required by TABLOCK, and it cannot fall back to its standard snapshot-based mechanism if the underlying storage volume lacks sufficient space or permissions to create the snapshot file. This is typically rooted in insufficient disk space on the volume hosting the data files, restrictive NTFS permissions preventing the SQL Server service account from creating snapshot files, or the replica being in a state that blocks snapshot isolation.

Step-by-Step Resolution Guide

Step 1: Remove the WITH TABLOCK Option

  • Re-run the DBCC CHECKDB command without explicitly specifying WITH TABLOCK, as this forces an exclusive lock that is incompatible with read-only secondary replicas.
  • Correct syntax: DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Allowing SQL Server to use its default snapshot-based consistency check avoids the exclusive locking requirement entirely.

Step 2: Verify Disk Space on the Secondary Replica Volume

  • Navigate to the data file directory (commonly D:\SQLData\ or the path defined in your instance configuration) and confirm at least 10-20% free space exists on the volume.
  • Internal database snapshots require sufficient space to hold copy-on-write pages during the check; low disk space will silently cause snapshot creation to fail.
  • Use Get-PSDrive in PowerShell or Disk Management on Windows Server 2025 to confirm available capacity.

Step 3: Check NTFS Permissions and Service Account Rights

  • Open File Explorer, navigate to the SQL Server data directory, right-click, and select Properties > Security.
  • Confirm the SQL Server service account (e.g., NT Service\MSSQLSERVER or your custom domain service account) has Full Control or at minimum Modify and Write permissions on the folder.
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER after applying permission changes.

Step 4: Run DBCC CHECKDB Against the Primary Replica Instead

  • If the secondary replica continues to fail, execute the consistency check on the primary replica using SQL Server Management Studio (SSMS) or sqlcmd.
  • Command: sqlcmd -S PrimaryServerName -E -Q "DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS"
  • This confirms whether the corruption/check issue is isolated to the secondary replica’s snapshot mechanism or indicates a genuine database integrity problem.

Step 5: Review the SQL Server Error Log for Underlying Snapshot Failure Details

  • Open SSMS, expand Management > SQL Server Logs, and review the most recent log entries surrounding the DBCC CHECK timestamp.
  • Look for accompanying errors such as Error 5123 (file creation failure) or Error 1807 (insufficient resources for snapshot), which indicate the specific root cause behind the failed snapshot.

Alternative or Verification Steps

  • To verify the fix, re-run DBCC CHECKDB on the secondary replica without TABLOCK and confirm it completes with “0 allocation errors and 0 consistency errors” in the Messages pane.
  • As an alternative, if secondary replica checks remain unreliable due to storage constraints, schedule DBCC CHECKDB exclusively against the primary replica using a SQL Server Agent job, ensuring full database integrity validation without impacting the read-only replica’s snapshot limitations.

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

Troubleshooting Guide: SQL Server Error 7935 – FILESTREAM Directory ID Mismatch

Why This Error Happens

Error 7935 occurs when the FILESTREAM directory structure on disk becomes inconsistent with the metadata stored in the system catalog views for a specific column’s object ID. This typically happens due to improper shutdowns, interrupted FILESTREAM garbage collection processes, or manual tampering with the underlying filesystem directories that back the FILESTREAM data container. It can also surface after a corrupted restore or an incomplete transaction log replay involving FILESTREAM-enabled tables.

Step-by-Step Resolution Guide

Step 1: Run a Full Consistency Check

  • Open SQL Server Management Studio (SSMS) connected to your Windows Server 2025 instance.
  • Execute DBCC CHECKDB ('YourDatabaseName') WITH DATA_PURITY, EXTENDED_LOGICAL_CHECKS; to confirm the scope of corruption.
  • Review the output specifically for references to FILESTREAM directory IDs and the associated object IDs to identify the orphaned table.

Step 2: Isolate the FILESTREAM Garbage Collection

  • Navigate to the FILESTREAM data container path (usually found via sys.database_files where type_desc = ‘FILESTREAM’).
  • Check for orphaned $FSLOG entries using: SELECT * FROM sys.filestream_tombstone_directory_metadata;
  • Manually trigger garbage collection by running a CHECKPOINT followed by restarting the SQL Server service to force the FILESTREAM garbage collector to sweep orphaned directories.

Step 3: Repair via Backup Restoration

  • Since FILESTREAM directory ID corruption is rarely fixed by REPAIR_ALLOW_DATA_LOSS, locate your most recent clean backup (.bak file).
  • Use the Windows Server 2025 File Explorer or PowerShell to verify the target restore volume has sufficient NTFS permissions for the NT SERVICE\MSSQLSERVER account.
  • Restore the database using: RESTORE DATABASE [YourDB] FROM DISK = 'E:\Backups\YourDB.bak' WITH REPLACE, RECOVERY;

Step 4: Rebuild the FILESTREAM Filegroup (If Backup is Unavailable)

  • If no valid backup exists, script out the schema and data for the affected table (excluding the FILESTREAM column) using the SSMS “Generate Scripts” wizard.
  • Drop the corrupted table entirely: DROP TABLE dbo.YourAffectedTable;
  • Recreate the table and filegroup associations from scratch, then re-import the salvageable data from a flat-file export.

Alternative or Verification Steps

  • Verification: Re-run DBCC CHECKDB on the specific table using DBCC CHECKTABLE('YourAffectedTable') WITH ALL_ERRORMSGS; to confirm the Directory ID and Object ID now match with zero allocation errors.
  • Alternative: If the server is virtualized on Windows Server 2025 Hyper-V, check the underlying VHDX for “fixed” vs. “dynamic” disk corruption, as sparse file mismanagement at the hypervisor level can mimic FILESTREAM directory ID errors.

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

Troubleshooting Guide: Error 7932 – FILESTREAM Directory ID Mismatch in SQL Server 2025

Why This Error Happens

Error 7932 occurs when SQL Server’s consistency checker (DBCC CHECKDB) detects a mismatch between the FILESTREAM directory ID stored in the system metadata and the actual directory structure on the filesystem. This typically results from corruption in the FILESTREAM filegroup, an improperly terminated I/O operation during a file write, or external manipulation of the FILESTREAM data container (such as manual deletion or renaming of folders/files by an administrator or antivirus software). It can also surface after an unclean shutdown, SAN/storage-level corruption, or a failed replication/mirroring sync involving FILESTREAM data.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to get the full list of affected object IDs and FILESTREAM directory IDs.
  • Cross-reference the object ID from the error message using SELECT OBJECT_NAME(object_id) FROM sys.objects WHERE object_id = <ID>; to identify the exact table.
  • Check the SQL Server error log (default path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related I/O or storage warnings.

Step 2: Inspect the FILESTREAM Data Container

  • Locate the FILESTREAM filegroup path via SELECT name, physical_name FROM sys.database_files WHERE type_desc = 'FILESTREAM';.
  • Open the directory in Windows Explorer (or dir /a in Command Prompt) and verify no folders have been manually deleted, renamed, or locked by antivirus/backup software.
  • Check Windows Security permissions on the FILESTREAM share — the SQL Server service account needs Full Control; use icacls "D:\FileStreamData" /grant "NT SERVICE\MSSQLSERVER":(OI)(CI)F if permissions appear broken.
  • Review Event Viewer (Windows Logs > System and Application) for disk, NTFS, or ReFS volume errors coinciding with the timestamp of corruption.

Step 3: Attempt Repair via Backup Restoration

  • If you have a clean, recent backup, restore the database using RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDB.bak' WITH REPLACE; — this is the safest fix since FILESTREAM repairs via CHECKDB are limited.
  • If no backup exists, run DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) only as a last resort, ideally on a copy of the database, since this may delete the corrupted FILESTREAM rows.
  • Take the database offline (ALTER DATABASE YourDatabaseName SET OFFLINE;) before performing file-level operations to avoid further metadata drift.

Step 4: Rebuild FILESTREAM Filegroup (If Repair Fails)

  • Create a new FILESTREAM filegroup and file using ALTER DATABASE YourDatabaseName ADD FILEGROUP FS_New CONTAINS FILESTREAM; followed by ALTER DATABASE YourDatabaseName ADD FILE (NAME = FS_Data, FILENAME = 'D:\NewFileStream') TO FILEGROUP FS_New;.
  • Migrate data from the corrupted table to a new table built on the healthy filegroup, then drop the old table and filegroup once data integrity is confirmed.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; after remediation — a clean pass with zero allocation/consistency errors confirms the fix.
  • If corruption recurs frequently, audit storage health (chkdsk D: /f) and disable third-party antivirus scanning on the FILESTREAM directory path to rule out external interference.

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

Troubleshooting Guide: SQL Server Error 7933 – FILESTREAM Directory ID Mismatch

Why This Error Happens

Error 7933 occurs when the FILESTREAM filesystem metadata (the directory ID stored in the NTFS reparse points) becomes out of sync with the internal page allocation metadata tracked by SQL Server for a given partition. This is typically caused by abrupt termination of a transaction involving FILESTREAM data (such as an unexpected shutdown, storage failure, or improper backup/restore), corruption in the FILESTREAM container, or manual tampering with files inside the FILESTREAM data directory outside of SQL Server. Because FILESTREAM relies on tight coordination between the NTFS file system and the database engine, any desynchronization between the two triggers this consistency error during DBCC CHECKDB operations.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB (YourDatabaseName) WITH ALL_ERRORMSGS, NO_INFOMSGS; in SQL Server Management Studio (SSMS) to capture the full list of affected objects and partitions.
  • Note the exact partition ID and table name associated with Error 7933 in the output.
  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related FILESTREAM I/O warnings around the same timestamp.

Step 2: Validate the FILESTREAM Container on Disk

  • Navigate to the FILESTREAM data container path (commonly D:\SQLData\FILESTREAM\<GUID>\$FSLOG and $FSDATA folders).
  • Use fsutil reparsepoint query <filepath> in an elevated Command Prompt on Windows Server 2025 to inspect whether the reparse point directory ID matches what SQL Server expects from the error message.
  • Ensure no external process (antivirus, backup agent, or manual Explorer access) has modified, deleted, or quarantined files inside this container, as this is the most common root cause.

Step 3: Restore From a Clean Backup (Preferred Fix)

  • Since FILESTREAM corruption is rarely repairable via REPAIR_ALLOW_DATA_LOSS, restore the affected database from the last known-good full backup plus transaction log backups using:
RESTORE DATABASE YourDatabaseName 
FROM DISK = 'E:\Backups\YourDatabaseName_Full.bak' 
WITH NORECOVERY;
RESTORE LOG YourDatabaseName 
FROM DISK = 'E:\Backups\YourDatabaseName_Log.trn' 
WITH RECOVERY;
  • Confirm the backup predates the corruption event identified in Step 1.

Step 4: If No Backup Is Available, Attempt Repair

  • As a last resort, run DBCC CHECKDB (YourDatabaseName, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS; in single-user mode (ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE; beforehand).
  • Understand this may drop or null out the corrupted FILESTREAM BLOB data for the affected partition to restore structural consistency.
  • Revert the database to multi-user mode afterward with ALTER DATABASE YourDatabaseName SET MULTI_USER;.

Alternative or Verification Steps

  • After applying the fix, re-run DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS; and confirm Error 7933 no longer appears in the output.
  • If corruption recurs frequently, check underlying storage health using Get-PhysicalDisk | Get-StorageReliabilityCounter in PowerShell on Windows Server 2025, as repeated FILESTREAM corruption often points to a failing disk or misconfigured antivirus exclusion for the FILESTREAM directory.

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

Why This Error Happens

Error 7930 occurs because certain DBCC commands (such as DBCC CHECKDB with specific repair options, or DBCC SHRINKFILE in some legacy configurations) are incompatible with a database that is actively participating in a Database Mirroring session. SQL Server blocks these maintenance operations because mirroring requires the principal and mirror databases to remain in a synchronized, transactionally consistent state, and certain DBCC operations could introduce page-level changes that break that synchronization. This is a protective mechanism rather than a corruption issue — the database engine simply refuses to proceed until mirroring is temporarily or permanently removed.

Step-by-Step Resolution Guide

Step 1: Confirm the Mirroring State of the Database

  • Open SQL Server Management Studio (SSMS) and connect to the instance reporting the error.
  • Run the following query to check mirroring status:
  SELECT name, mirroring_state_desc FROM sys.database_mirroring WHERE database_id = DB_ID('YourDatabaseName');
  • Confirm that mirroring_state_desc is not NULL, which indicates mirroring is active.

Step 2: Remove Mirroring from the Database

  • On the principal server instance, run:
  ALTER DATABASE [YourDatabaseName] SET PARTNER OFF;
  • This breaks the mirroring session without deleting any data, allowing DBCC commands to run normally.
  • If using a witness server, confirm it is also disconnected properly to avoid orphaned configuration entries.

Step 3: Run the Required DBCC Command

  • Execute the original DBCC command that previously failed, for example:
  DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Verify that the command completes without raising Error 7930.

Step 4: Re-Establish Mirroring (If Required)

  • Once DBCC maintenance is complete, reconfigure mirroring using the Database Mirroring Wizard in SSMS or via T-SQL:
  ALTER DATABASE [YourDatabaseName] SET PARTNER = 'TCP://MirrorServer:5022';
  • Ensure certificates, endpoints, and firewall rules on Windows Server 2025 (port 5022 by default) are still valid before re-enabling mirroring.

Alternative or Verification Steps

  • After re-establishing mirroring, run SELECT mirroring_state_desc FROM sys.database_mirroring WHERE database_id = DB_ID('YourDatabaseName'); and confirm the state returns to SYNCHRONIZED.
  • If mirroring cannot be removed due to availability requirements, consider migrating to Always On Availability Groups, which support most DBCC operations without requiring full removal of high-availability configurations.

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

Troubleshooting Guide: Error 7931 – FILESTREAM Directory ID Seen Two Times

Why This Error Happens

This error occurs when SQL Server’s internal consistency checker (DBCC CHECKDB) detects duplicate FILESTREAM directory GUIDs across partitions, indicating corruption in the FILESTREAM filegroup’s metadata structure. This typically results from improper shutdowns, storage-level corruption, or manual/external manipulation of files within the FILESTREAM data container outside of SQL Server’s control. It can also surface after a failed or interrupted restore/attach operation involving FILESTREAM-enabled databases.

Step-by-Step Resolution Guide

Step 1: Run a Full Consistency Check

  • Open SQL Server Management Studio (SSMS) or a query window connected to the affected instance.
  • Execute DBCC CHECKDB ('YourDatabaseName') WITH ALL_ERRORMSGS, NO_INFOMSGS; to get a complete list of corruption errors tied to Error 7931.
  • Note the specific partition ID and FILESTREAM directory GUID referenced in the output for cross-referencing.

Step 2: Inspect the FILESTREAM Data Container

  • Navigate to the FILESTREAM filegroup path (commonly found under a path like D:\SQLData\FileStreamContainer\).
  • Verify that no external processes (antivirus, backup agents, or manual file explorer actions) have modified, duplicated, or renamed the internal GUID-named folders.
  • Exclude the FILESTREAM container path from antivirus real-time scanning via Windows Security settings to prevent file-lock conflicts that can cause metadata mismatches.

Step 3: Restore from a Clean Backup

  • Since FILESTREAM directory corruption is rarely repairable via REPAIR_ALLOW_DATA_LOSS without losing the affected BLOB data, locate the most recent verified-clean full backup.
  • Use RESTORE DATABASE [YourDatabaseName] FROM DISK = 'E:\Backups\YourDB.bak' WITH REPLACE, RECOVERY; to restore the database to a consistent state.
  • Ensure the destination server has the FILESTREAM feature enabled via SQL Server Configuration Manager before initiating the restore.

Step 4: Rebuild the FILESTREAM Filegroup (If Restore Is Not Viable)

  • If no backup exists, create a new FILESTREAM filegroup and file group container using ALTER DATABASE YourDatabaseName ADD FILEGROUP FileStreamGroup2 CONTAINS FILESTREAM;.
  • Migrate accessible BLOB data from the corrupted filegroup to the new one using INSERT INTO NewTable SELECT * FROM OldTable WHERE DocumentID NOT IN (SELECT DocumentID FROM CorruptedRows);.
  • Drop the old corrupted filegroup once data migration is confirmed complete.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS; after remediation to confirm Error 7931 no longer appears in the output.
  • If the issue persists on Windows Server 2025, check the underlying storage subsystem (SAN/NAS or local disk) for hardware-level errors using chkdsk D: /f /r on the volume hosting the FILESTREAM container.