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

Troubleshooting Guide: SQL Server Error 8422

Why This Error Happens

Error 8422 in Microsoft SQL Server 2025 typically occurs when a distributed transaction or linked server operation cannot properly negotiate with the Microsoft Distributed Transaction Coordinator (MSDTC) service due to security context mismatches. This is commonly caused by MSDTC not being properly configured for network access, inconsistent authentication settings between the local and remote servers, or firewall rules blocking the required RPC and MSDTC communication ports. In some cases, this also stems from corrupted MSDTC configuration data in the Windows registry after a server migration or OS upgrade to Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify and Reconfigure MSDTC Settings

  • Open Component Services by running dcomcnfg from the Run dialog.
  • Navigate to Component Services > Computers > My Computer > Distributed Transaction Coordinator > Local DTC.
  • Right-click Local DTC, select Properties, and go to the Security tab.
  • Ensure Network DTC Access, Allow Inbound, Allow Outbound, and No Authentication Required (or Mutual Authentication Required for domain-joined servers) are enabled.
  • Restart the MSDTC service after applying changes: net stop msdtc && net start msdtc.

Step 2: Check Firewall and Port Configuration

  • Confirm that the Windows Defender Firewall allows MSDTC traffic by enabling the Distributed Transaction Coordinator rule group.
  • Run the following PowerShell command to verify: Get-NetFirewallRule -DisplayGroup "Distributed Transaction Coordinator".
  • If using a custom RPC port range, ensure it is open on both the source and target servers (default dynamic RPC range is 49152–65535).

Step 3: Validate SQL Server Service Account Permissions

  • Open SQL Server Configuration Manager and confirm the SQL Server service account has the necessary permissions to access MSDTC.
  • Grant the service account Log on as a service rights via secpol.msc > Local Policies > User Rights Assignment.
  • Restart the SQL Server service: net stop MSSQLSERVER && net start MSSQLSERVER.

Step 4: Rebuild MSDTC if Configuration Is Corrupted

  • If the issue persists, uninstall and reinstall MSDTC using msdtc -uninstall followed by msdtc -install.
  • Restart the server to ensure the service reinitializes cleanly.

Alternative or Verification Steps

  • Test the fix by running a sample distributed transaction query (e.g., a linked server call using BEGIN DISTRIBUTED TRANSACTION) and confirm it completes without Error 8422.
  • If the error persists, use DTCPing or DTCTester utility tools to isolate whether the issue lies in network connectivity versus local MSDTC misconfiguration.

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

Troubleshooting Guide: SQL Server Error 8420 – Missing Conversation Group

Why This Error Happens

Error 8420 occurs when a Service Broker operation (such as SEND or END CONVERSATION) attempts to execute without a valid conversation group ID bound to the current session context. This typically happens when the conversation handle has already been closed, the conversation group was never properly initialized via BEGIN DIALOG, or the session’s context was lost due to a transaction rollback. Corrupted Service Broker queue metadata or improper handling of conversation handles across multiple batches can also trigger this failure in SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify the Conversation Handle Context

  • Check that the stored procedure or script explicitly retrieves the conversation_handle using RECEIVE before attempting to send or end a dialog.
  • Run the following to confirm an active conversation group exists:
SELECT conversation_handle, conversation_group_id, state 
FROM sys.conversation_endpoints;
  • If no rows return for the expected dialog, the conversation group has already been terminated or was never established.

Step 2: Inspect Service Broker Queue and Transaction Scope

  • Ensure the RECEIVE statement and the subsequent SEND/END CONVERSATION occur within the same transaction scope.
  • Validate Service Broker is enabled on the database:
SELECT is_broker_enabled FROM sys.databases WHERE name = 'YourDatabaseName';
  • If is_broker_enabled returns 0, enable it:
ALTER DATABASE YourDatabaseName SET ENABLE_BROKER;

Step 3: Rebuild or Reset Corrupted Conversation Metadata

  • If orphaned conversation groups are suspected, query for stale endpoints:
SELECT * FROM sys.conversation_endpoints WHERE state_desc = 'CLOSED';
  • End any lingering conversations manually:
END CONVERSATION 'conversation_handle_value' WITH CLEANUP;
  • Restart the SQL Server Service Broker task on Windows Server 2025 via SQL Server Configuration Manager to clear cached session states.

Step 4: Review Application Code for Handle Reuse

  • Check client-side .NET or T-SQL code for cases where a conversation_handle variable is reused after a conversation has already ended.
  • Ensure each BEGIN DIALOG CONVERSATION call stores a fresh handle in a local variable before any SEND operation references it.

Alternative or Verification Steps

  • To verify the fix, execute a full send/receive cycle manually in SQL Server Management Studio (SSMS) and confirm no Error 8420 is raised, then check sys.transmission_queue for stuck messages.
  • If the issue persists, drop and recreate the affected Service Broker queue and contract, then re-test the dialog initiation from a clean session.

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

Troubleshooting Guide: Error 8419 – END CONVERSATION WITH ERROR Requires Both Error Code and Description

Why This Error Happens

Error 8419 occurs when the END CONVERSATION ... WITH ERROR statement in a Service Broker conversation is executed without supplying both the error_code and error_description parameters. SQL Server’s Service Broker enforces a strict validation rule that neither value can be NULL when explicitly ending a conversation with an error state, since both fields are required to populate the error information transmitted to the other endpoint. This typically stems from malformed T-SQL scripts, poorly generated dynamic SQL, or application code/stored procedures that were updated to use the WITH ERROR clause but failed to pass complete parameters.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Statement

  • Review the stored procedure, trigger, or application code that calls END CONVERSATION @handle WITH ERROR = @code DESCRIPTION = @desc.
  • Use SQL Server Profiler or Extended Events (sqlserver.error_reported) to capture the exact statement firing Error 8419.
  • Check Service Broker activation procedures under Object Explorer > Databases > [YourDB] > Service Broker > Queues for recently modified activation stored procedures.

Step 2: Correct the Syntax to Include Both Parameters

  • Ensure the statement always supplies a valid integer for error_code and a non-null string for error_description, for example:
  END CONVERSATION @handle 
      WITH ERROR = 50000 
      DESCRIPTION = 'Conversation terminated due to validation failure';
  • If values are sourced from variables, add a NULL check before execution:
  IF @ErrorCode IS NULL SET @ErrorCode = 50001;
  IF @ErrorDescription IS NULL SET @ErrorDescription = 'Unspecified error during message processing';

Step 3: Patch Dynamic SQL or ORM-Generated Queries

  • If the conversation is being ended via dynamically constructed SQL (common in .NET or PowerShell automation scripts on Windows Server 2025), inspect the string concatenation logic for missing parameter bindings.
  • Confirm parameters are explicitly cast to the correct types (INT for error code, NVARCHAR(3000) for description) to avoid implicit NULL coercion.
  • Redeploy the corrected stored procedure using:
  EXEC sp_recompile 'YourStoredProcedureName';

Step 4: Clear and Rebuild Broken Conversation Handles

  • If existing conversations are stuck in an error-eligible state due to prior failed END CONVERSATION attempts, query the current state:
  SELECT conversation_handle, state, lifetime 
  FROM sys.conversation_endpoints 
  WHERE state = 'ER';
  • Manually close any orphaned endpoints with a valid error code/description pair before redeploying the fixed code.

Alternative or Verification Steps

  • Verify the fix by re-running the corrected procedure and confirming no Error 8419 appears in SQL Server Logs (EXEC xp_readerrorlog 0, 1, N'8419';) or in the Windows Server 2025 Event Viewer under Applications and Services Logs > MSSQLSERVER.
  • As an alternative, if error details are genuinely unavailable at runtime, use END CONVERSATION @handle; (without the WITH ERROR clause) to gracefully close the conversation instead of forcing an error state.

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

Troubleshooting Guide: SQL Server Error 8417 – “The Service Contract Name Is NULL”

Why This Error Happens

This error occurs when a Service Broker command, such as CREATE QUEUE, CREATE SERVICE, or BEGIN DIALOG CONVERSATION, is executed without explicitly specifying a valid service contract name, or when the referenced contract name is passed as a NULL value or empty string. This typically happens due to a scripting error, an incomplete T-SQL template, or a dynamic SQL statement that fails to concatenate the contract name correctly before execution. It can also surface when application code or an ORM-generated query omits the ON CONTRACT clause required for service-to-contract binding.

Step-by-Step Resolution Guide

Step 1: Review the T-SQL Script Causing the Error

  • Locate the specific CREATE SERVICE or ALTER SERVICE statement that triggered Error 8417 in the SQL Server Error Log or Activity Monitor.
  • Check if the ON CONTRACT clause is missing or if a variable intended to hold the contract name is NULL.
  • Example of a faulty statement: CREATE SERVICE [MyService] ON CONTRACT [NULL];

Step 2: Verify Contract Existence in the Database

  • Run the following query to confirm the contract exists in the target database:
  SELECT name FROM sys.service_contracts;
  • If the contract is missing, create it using:
  CREATE CONTRACT [MyContract] ([MyMessageType] SENT BY INITIATOR);

Step 3: Correct the Service Definition

  • Update the broken script to explicitly reference the valid contract name.
  • Execute the corrected syntax:
  CREATE SERVICE [MyService] ON CONTRACT [MyContract];
  • Ensure there are no trailing spaces or empty string values ('') passed in dynamic SQL variables, as SQL Server treats these differently than NULL but can cause similar binding failures.

Step 4: Check Application/Connection String Variables

  • If the error originates from an application (e.g., a .NET service running on Windows Server 2025), inspect the configuration files (app.config or appsettings.json) for the variable that defines the ServiceContractName.
  • Ensure the environment variable or config key is populated correctly before the connection is initialized.

Alternative or Verification Steps

  • Verification: Re-run the CREATE SERVICE script after the fix. Success is confirmed by querying sys.services and sys.service_contracts to ensure the new service is now listed and correctly mapped to the specific contract ID.
  • Alternative: If using a deployment pipeline (DACPAC) that generates this script automatically, revert to a previous schema version and manually patch the specific .sql file within the project folder to hardcode the contract name before redeploying to Windows Server 2025.

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

Troubleshooting Guide: Error 8418 – “The Conversation Handle Is Missing”

Why This Error Happens

Error 8418 occurs in SQL Server Service Broker when a SEND or END CONVERSATION statement is executed without providing a valid, in-scope conversation handle variable. This typically happens because the handle was never populated (e.g., BEGIN DIALOG failed silently or was skipped), the variable was declared but not assigned, or the conversation handle went out of scope due to a transaction rollback. It can also occur if application code reuses a handle variable after the conversation has already been ended or has expired.

Step-by-Step Resolution Guide

Step 1: Verify the Conversation Handle Variable Declaration

  • Check that the handle variable is explicitly declared as UNIQUEIDENTIFIER before use.
  • Confirm that BEGIN DIALOG CONVERSATION @handle FROM SERVICE ... TO SERVICE ... executed successfully and populated the variable.
  • Add a PRINT @handle or SELECT @handle AS DialogHandle immediately after the BEGIN DIALOG call to confirm it is not NULL.

Step 2: Inspect Transaction Scope and Rollbacks

  • Ensure the BEGIN DIALOG, SEND, and END CONVERSATION statements are wrapped in the same transaction scope where possible.
  • Check SQL Server error logs at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for any prior rollback events that may have invalidated the handle.
  • Re-run the stored procedure with SET XACT_ABORT ON to prevent partial transaction states from leaving the handle undefined.

Step 3: Query Active Conversation Endpoints

  • Run the following to confirm whether the conversation handle actually exists in the current session:
  • SELECT conversation_handle, state, far_service FROM sys.conversation_endpoints;
  • If the handle is missing from this result set, the dialog was never properly initiated or has already been cleaned up.
  • Re-issue BEGIN DIALOG CONVERSATION to generate a fresh handle before retrying SEND.

Step 4: Review Application-Level Handle Management

  • Audit application or .NET/ADO code that passes conversation handles as parameters to stored procedures.
  • Verify the parameter type matches UNIQUEIDENTIFIER and is not being truncated, cast incorrectly, or passed as an empty string.
  • Add explicit NULL checks in application code before calling SEND ON CONVERSATION @handle.

Alternative or Verification Steps

  • Verify the fix by executing a test BEGIN DIALOG, SEND, and END CONVERSATION sequence manually in SQL Server Management Studio and confirming no Error 8418 is raised.
  • If the issue persists, enable Service Broker diagnostic tracing via Extended Events (sqlserver.broker_conversation events) to capture the exact point where the handle becomes invalid.

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

Troubleshooting Guide: SQL Server Error 8415 — Activated Task Aborted Due to Unresolved Transaction

Why This Error Happens

This error occurs when a stored procedure invoked by a Service Broker activated task begins a transaction (explicitly via BEGIN TRANSACTION or implicitly) but exits without issuing a matching COMMIT or ROLLBACK. SQL Server’s Service Broker activation feature requires that the transaction state be fully resolved before the procedure returns control, because the activated task runs in an internal worker context that cannot leave open transactions on the queue. This is almost always caused by poor error handling (missing TRY...CATCH blocks), early RETURN statements that skip cleanup logic, or unhandled exceptions that bypass the COMMIT/ROLLBACK line entirely.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Stored Procedure

  • Check the full error message text — it includes the exact procedure name (%ls) that failed to close its transaction.
  • Open SQL Server Management Studio (SSMS) and navigate to Databases > [YourDB] > Service Broker > Queues to confirm which queue’s activation procedure is tied to this object.
  • Review the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for the timestamp and session ID associated with Error 8415.

Step 2: Audit and Fix the Transaction Logic in the Procedure

  • Open the procedure definition using sp_helptext '[YourProcedureName]' or script it out via SSMS.
  • Wrap all transactional logic inside a BEGIN TRY ... END TRY / BEGIN CATCH ... END CATCH block.
  • Inside the CATCH block, add logic to check @@TRANCOUNT > 0 and issue a ROLLBACK TRANSACTION before re-throwing or logging the error.
  • Ensure every BEGIN TRANSACTION has a corresponding COMMIT TRANSACTION on all code paths, including early exits (RETURN statements).
  • Example pattern to implement:
  BEGIN TRY
      BEGIN TRANSACTION;
      -- business logic here
      COMMIT TRANSACTION;
  END TRY
  BEGIN CATCH
      IF @@TRANCOUNT > 0
          ROLLBACK TRANSACTION;
      THROW;
  END CATCH;

Step 3: Validate Queue and Activation Settings

  • Run SELECT * FROM sys.service_queues WHERE name = 'YourQueueName'; to confirm is_activation_enabled is set to 1 and max_queue_readers is configured appropriately (too high a value can mask concurrency issues during testing).
  • Temporarily disable activation (ALTER QUEUE [YourQueueName] WITH ACTIVATION (STATUS = OFF);) while you test the corrected procedure manually to avoid repeated failed activations flooding the log.
  • Re-enable activation once the procedure has been validated (ALTER QUEUE [YourQueueName] WITH ACTIVATION (STATUS = ON);).

Step 4: Redeploy and Monitor

  • Deploy the corrected stored procedure to the target database.
  • Use SQL Server Profiler or Extended Events (sqlserver.error_reported filtered on error number 8415) to monitor for recurrence.
  • Check sys.transmission_queue and the target queue’s message count to ensure messages are being processed without piling up.

Alternative or Verification Steps

  • Manually invoke the corrected procedure with a test message from the queue and run SELECT @@TRANCOUNT; immediately after execution — it should return 0.
  • If the error persists, review any nested stored procedures called within the activation procedure, as an unresolved transaction in a child procedure can still trigger Error 8415 at the parent level.

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

Troubleshooting Guide: Error 8413 – Invalid Broker Instance Syntax

Why This Error Happens

Error 8413 occurs when SQL Server Service Broker receives a broker instance identifier that exceeds the maximum allowed length, typically because the GUID-based instance string has been malformed or concatenated incorrectly during a dialog conversation request. This often happens when application code manually constructs broker instance strings instead of retrieving them programmatically from sys.databases or sys.conversation_endpoints. It can also surface after a database restore, mirroring failover, or Always On availability group role change where the service_broker_guid was duplicated, corrupted, or improperly appended to existing connection strings.

Step-by-Step Resolution Guide

Step 1: Verify the Broker Instance GUID Length

  • Run the following query to inspect the current broker instance identifier:
  SELECT name, service_broker_guid, is_broker_enabled 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • Confirm the service_broker_guid is a standard 36-character GUID (including hyphens) and not duplicated or truncated.
  • Check application logs for the exact malformed string being passed in the BEGIN DIALOG or routing statement.

Step 2: Inspect and Correct Application Connection Strings

  • Open the application code or SSIS package responsible for initiating the dialog conversation.
  • Look for string concatenation logic that builds the broker instance (e.g., 'Current Database='+@BrokerInstance) and ensure it isn’t appending the GUID twice.
  • Replace hardcoded broker instance strings with a dynamic lookup:
  SELECT service_broker_guid FROM sys.databases WHERE database_id = DB_ID();

Step 3: Reset the Service Broker GUID (If Corrupted)

  • If the GUID appears corrupted after a restore or mirroring event, regenerate it using:
  ALTER DATABASE YourDatabaseName SET NEW_BROKER WITH ROLLBACK IMMEDIATE;
  • Alternatively, if you need to preserve existing conversations, use:
  ALTER DATABASE YourDatabaseName SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
  • Restart the SQL Server service via Services.msc on Windows Server 2025/Windows 11, or run:
  Restart-Service -Name MSSQLSERVER -Force

Step 4: Clear Stale Routing and Endpoint Configurations

  • Navigate to SQL Server Management Studio (SSMS) > Service Broker node and review existing Routes.
  • Drop and recreate any routes referencing the old or invalid broker instance:
  DROP ROUTE IF EXISTS YourRouteName;
  CREATE ROUTE YourRouteName 
  WITH SERVICE_NAME = 'YourServiceName', 
  BROKER_INSTANCE = 'CorrectGUIDHere', 
  ADDRESS = 'TCP://YourServerAddress:4022';

Alternative or Verification Steps

  • After applying fixes, send a test message through the dialog conversation and confirm it is processed without raising Error 8413 in the SQL Server Error Log (located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG on Windows Server 2025).
  • If the issue persists, enable Service Broker diagnostic trace flags (2537) temporarily to capture detailed message routing data for deeper analysis.

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

Troubleshooting Guide: SQL Server Error 8414 – Invalid Conversation Group ID

Why This Error Happens

Error 8414 occurs when a Service Broker operation references a conversation group ID that does not exist in the current database context or has already been ended. This typically happens when a GET CONVERSATION GROUP or RECEIVE statement is executed against a queue using a stale, cached, or manually constructed group ID rather than one retrieved dynamically from the queue itself. It can also occur after a database restore, mirroring failover, or Service Broker queue corruption where conversation group metadata becomes desynchronized from the sys.conversation_endpoints table.

Step-by-Step Resolution Guide

Step 1: Verify the Conversation Group ID Source

  • Confirm the application is not hardcoding or caching a conversation_group_id across sessions.
  • Query the current valid groups using:
  SELECT conversation_group_id, conversation_handle, state_desc 
  FROM sys.conversation_endpoints;
  • Ensure the ID being passed to GET CONVERSATION GROUP matches an active row returned above.

Step 2: Check Service Broker Queue and Service State

  • Validate that the target queue is enabled and not disabled due to poison message handling:
  SELECT name, is_receive_enabled, is_enqueue_enabled 
  FROM sys.service_queues 
  WHERE name = 'YourQueueName';
  • If disabled, re-enable it:
  ALTER QUEUE YourQueueName WITH STATUS = ON;
  • Confirm the associated Service Broker service exists using SELECT * FROM sys.services;.

Step 3: Inspect for Orphaned or Ended Conversations

  • Check for conversations that may have already ended, leaving the group ID invalid:
  SELECT * FROM sys.conversation_endpoints 
  WHERE state_desc = 'CLOSED' OR state_desc = 'DISCONNECTED';
  • Clean up orphaned conversations if necessary using END CONVERSATION with the correct handle (not group ID).
  • On Windows Server 2025, check Event Viewer under Applications and Services Logs > MSSQLSERVER for correlating Broker errors (Event ID 9675 or 9637).

Step 4: Validate Service Broker Configuration Integrity

  • Run DBCC CHECKDB on the affected database to rule out corruption affecting Broker system tables:
  DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • If corruption is found in Broker-related pages, restore from a known good backup rather than attempting repair, as REPAIR_ALLOW_DATA_LOSS can further damage conversation metadata.

Step 5: Restart Service Broker for the Database

  • If the GUID mismatch persists due to a stuck internal state, toggle Service Broker off and on:
  ALTER DATABASE YourDatabaseName SET DISABLE_BROKER;
  ALTER DATABASE YourDatabaseName SET ENABLE_BROKER;
  • Note: This action will terminate all active conversations, so ensure no critical messages are in-flight.

Alternative or Verification Steps

  • To verify the fix, rerun the application’s message-receiving logic and confirm RECEIVE statements return rows without raising Error 8414 in the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • If the error persists after Service Broker restart, drop and recreate the specific Queue/Service pair (not the entire Broker configuration) to force SQL Server to regenerate clean conversation group metadata.

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

Troubleshooting Guide: Error 8412 – “The syntax of the service name ‘%.*ls’ is invalid.”

Why This Error Happens

Error 8412 occurs when SQL Server 2025 attempts to parse a Service Broker service name that doesn’t conform to valid naming conventions, typically caused by improperly formatted names during CREATE SERVICE or CREATE ROUTE statements. This often results from unescaped special characters, incorrect use of delimited identifiers, or a service name exceeding the 256-character limit imposed by Service Broker. Corrupted system catalog entries from a failed upgrade or migration to SQL Server 2025 can also trigger this validation failure.

Step-by-Step Resolution Guide

Step 1: Review the Offending T-SQL Statement

  • Locate the exact CREATE SERVICE, ALTER SERVICE, or CREATE ROUTE statement that triggered the error in your script or application log.
  • Check for unescaped special characters (e.g., /, \, spaces) in the service name that require square bracket delimiters, such as [MyApp/ServiceName].
  • Verify the name does not exceed 256 Unicode characters, per Service Broker naming rules.

Step 2: Correct the Service Name Syntax

  • Rename the service using a properly delimited identifier, for example:
    CREATE SERVICE [//MyCompany.com/MyApp/OrderService] ON QUEUE OrderQueue;
  • Avoid using reserved SQL keywords or leading numeric characters without bracket delimiters.
  • Run the corrected script in SQL Server Management Studio (SSMS) 21 connected to your SQL Server 2025 instance.

Step 3: Validate Service Broker Configuration

  • Open a query window in SSMS and run:
    SELECT name, service_id FROM sys.services;
  • Confirm no legacy or duplicate entries exist with malformed names from a previous migration.
  • If corruption is suspected, run DBCC CHECKDB against the affected database to rule out catalog inconsistencies.

Step 4: Check Windows Server 2025 / Windows 11 Locale Settings

  • Open Control Panel > Region > Administrative > Change system locale.
  • Ensure the system locale matches the collation settings used by your SQL Server 2025 instance, as mismatched Unicode handling can cause string parsing errors in service names.
  • Restart the SQL Server service via services.msc after any locale change.

Alternative or Verification Steps

  • Re-run the original CREATE SERVICE or CREATE ROUTE statement after correction and confirm no Error 8412 is raised; verify the entry appears correctly using SELECT * FROM sys.services WHERE name = 'YourServiceName';.
  • If the error persists, drop and recreate the Service Broker queue and service objects from scratch using a minimal test script to isolate whether the issue is name-specific or related to broader database corruption.

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

Troubleshooting Guide: SQL Server Error 8410 — Conversation Timer Exceeds Lifetime

Why This Error Happens

Error 8410 occurs when a Service Broker application attempts to set a conversation timer (using BEGIN CONVERSATION TIMER) with a duration that extends beyond the configured lifetime of the conversation dialog. This typically happens because the conversation was initiated with an explicit LIFETIME value that is shorter than the timer being requested, or because the default dialog lifetime was not accounted for in application logic. The mismatch is almost always a T-SQL coding issue rather than a server configuration or permissions problem.

Step-by-Step Resolution Guide

Step 1: Identify the Conversation Lifetime Setting

  • Query the sys.conversation_endpoints system view to inspect the lifetime column for the affected conversation_handle.
  • Run the following to check active conversations:
  SELECT conversation_handle, lifetime, state, state_desc
  FROM sys.conversation_endpoints;
  • Confirm whether the dialog was started with a custom LIFETIME clause in the original BEGIN DIALOG CONVERSATION statement.

Step 2: Review and Correct the BEGIN DIALOG CONVERSATION Statement

  • Locate the stored procedure or script that initiates the conversation.
  • Ensure the LIFETIME parameter (in seconds) is set high enough to accommodate any downstream timer calls:
  BEGIN DIALOG CONVERSATION @handle
      FROM SERVICE [InitiatorService]
      TO SERVICE 'TargetService'
      ON CONTRACT [MyContract]
      WITH ENCRYPTION = OFF, LIFETIME = 3600;
  • If no LIFETIME is specified, remember the default is the maximum value (~69 years), so an explicit short lifetime is usually the culprit.

Step 3: Correct the BEGIN CONVERSATION TIMER Call

  • Adjust the TIMER (n) value so it does not exceed the dialog’s lifetime value in seconds.
  • Example fix, ensuring timer is less than or equal to lifetime:
  BEGIN CONVERSATION TIMER (@handle)
      TIMEOUT = 1800; -- must be <= conversation LIFETIME
  • Deploy the corrected stored procedure or script to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Scripts\ (or your source control repository) and re-run the Service Broker transaction.

Step 4: Restart the Service Broker Queue (If Timer Was Left Pending)

  • If the error occurred mid-transaction, check for orphaned conversations using sys.transmission_queue.
  • Use SQL Server Configuration Manager (search “SQL Server Configuration Manager” in Windows 11 Start Menu) to restart the SQL Server (MSSQLSERVER) service if queues appear stuck.
  • Re-enable the queue if it was disabled automatically:
  ALTER QUEUE [MyQueue] WITH STATUS = ON;

Alternative or Verification Steps

  • Re-run the transaction and confirm no Error 8410 appears in SQL Server Error Log (Application log in Windows Event Viewer, Event source: MSSQLSERVER).
  • As an alternative, omit the LIFETIME clause entirely in BEGIN DIALOG CONVERSATION during development/testing to rule out timer-vs-lifetime mismatches, then reintroduce a properly calculated value for production.

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

Troubleshooting Guide: SQL Server Error 8411 – Invalid Dialog Lifetime Value

Why This Error Happens

Error 8411 occurs when a Service Broker command such as BEGIN DIALOG CONVERSATION is executed with a LIFETIME parameter that falls outside the valid range accepted by SQL Server, which is 1 through 2,147,483,647 seconds. This typically results from a hardcoded value in application code or a T-SQL script that passes zero, a negative number, or a value exceeding the maximum int boundary. It can also surface after a migration or upgrade to SQL Server 2025 if legacy Service Broker code relied on an undocumented or previously tolerated edge-case value.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Procedure

  • Check the SQL Server error log or Extended Events session for the exact statement raising Error 8411.
  • Use SQL Server Management Studio (SSMS) on Windows 11 or Windows Server 2025 to run a trace filtered on Error Number = 8411.
  • Review stored procedures, triggers, or application connection strings that call BEGIN DIALOG CONVERSATION ... WITH LIFETIME =.

Step 2: Correct the Lifetime Value in the Script

  • Open the identified script in SSMS and locate the LIFETIME parameter.
  • Replace the invalid value with a number between 1 and 2147483647 (seconds), for example:
  BEGIN DIALOG CONVERSATION @DialogHandle
      FROM SERVICE [InitiatorService]
      TO SERVICE 'TargetService'
      ON CONTRACT [MyContract]
      WITH LIFETIME = 86400, ENCRYPTION = OFF;
  • Avoid passing variables that could resolve to 0, NULL, or negative integers; add a validation check before the BEGIN DIALOG call.

Step 3: Audit Application and Middleware Code

  • Search application source code (C#, Java, or PowerShell scripts) for any dynamic calculation of dialog lifetime (e.g., DateTime.Now.AddSeconds(x) logic feeding into SQL parameters).
  • Ensure configuration files (web.config, appsettings.json, or environment variables) do not inject an out-of-range value from a misconfigured setting.
  • Deploy the corrected code to your Windows Server 2025 application tier and restart the relevant service via services.msc or Restart-Service in PowerShell.

Step 4: Validate Service Broker Configuration

  • Run SELECT is_broker_enabled FROM sys.databases WHERE name = 'YourDatabase'; to confirm Service Broker is active.
  • If Service Broker was recently re-enabled after a restore, verify that no orphaned conversations are retaining stale lifetime metadata by querying sys.conversation_endpoints.

Alternative or Verification Steps

  • Re-run the corrected BEGIN DIALOG CONVERSATION statement in SSMS and confirm no Error 8411 is returned; check sys.transmission_queue for successful message delivery.
  • If the error persists, enable SQL Server Profiler or Extended Events to capture the exact parameter value being passed at runtime, confirming whether the fix was deployed to all application instances.

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

Troubleshooting Guide: SQL Server Error 8409 – Service Contract Mismatch

Why This Error Happens

Error 8409 occurs when a Service Broker message is sent to a service that doesn’t recognize or support the specified contract, typically because the target service definition was altered, dropped, or recreated without the matching contract binding. This often happens after a database restore, replication mismatch, or manual schema changes where the service’s contract list falls out of sync with the message type being sent. It can also occur when routing tables direct traffic to the wrong database or service name, causing a valid message to arrive at an incompatible endpoint.

Step-by-Step Resolution Guide

Step 1: Verify the Target Service and Contract Binding

  • Run SELECT * FROM sys.services; on the target database to confirm the service exists and is spelled exactly as referenced in the error.
  • Cross-reference with SELECT * FROM sys.service_contracts; to ensure the contract name tied to the message matches what the service supports.
  • Check sys.service_contract_usages to confirm the service-to-contract mapping hasn’t been dropped or renamed.

Step 2: Rebuild the Service with Correct Contract Association

  • If the contract is missing from the service, drop and recreate the service using:
  DROP SERVICE [TargetServiceName];
  CREATE SERVICE [TargetServiceName]
  ON QUEUE [YourQueueName]
  ([YourContractName]);
  • Ensure the queue referenced still exists and is not disabled (SELECT * FROM sys.service_queues;).
  • Restart the SQL Server Service Broker on the database: ALTER DATABASE [YourDB] SET ENABLE_BROKER;

Step 3: Validate Routing and Remote Service Bindings

  • Inspect sys.routes to confirm the route isn’t pointing to an outdated or incorrect service name on a remote instance.
  • If using cross-database or cross-instance messaging, verify the Remote Service Binding matches the correct certificate and service name.
  • On Windows Server 2025, check the Windows Firewall rules (Control Panel > Windows Defender Firewall > Advanced Settings) to confirm the Service Broker port (default 4022) isn’t being redirected or blocked, causing messages to land on a stale endpoint.

Step 4: Clear and Resend Poison Messages

  • Query the queue for stuck conversations: SELECT * FROM [YourQueueName];
  • If a poisoned message is causing repeated failures, end the conversation manually:
  END CONVERSATION 'conversation_handle' WITH CLEANUP;
  • Restart the initiating application or stored procedure to generate a fresh message against the corrected contract.

Alternative or Verification Steps

  • Verify the fix by sending a test message through the service and confirming it reaches the queue without generating Error 8409 in the SQL Server Error Log (check via EXEC sp_readerrorlog 0, 1, 'Service Broker';).
  • If the error persists, as an alternative, drop and fully recreate the Message Type, Contract, Queue, and Service in the correct dependency order, then re-establish any remote routes to rule out metadata corruption.

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

Troubleshooting Guide: SQL Server Error 8407 – Invalid Header Fields in Service Broker Message

Why This Error Happens

Error 8407 occurs when the Service Broker endpoint receives a TDS (Tabular Data Stream) message whose header does not conform to the expected Service Broker protocol structure. This typically happens because a non-Service Broker application or process (such as a port scanner, load balancer health check, or misconfigured client) is connecting directly to the Service Broker TCP endpoint. It can also result from network-level packet corruption, a mismatched SQL Server version handshake, or a firewall/proxy altering packet contents in transit.

Step-by-Step Resolution Guide

Step 1: Identify What Is Connecting to the Service Broker Port

  • Open SQL Server Configuration Manager and note the configured Service Broker endpoint port (commonly 4022).
  • Run netstat -ano | findstr <port> in an elevated Command Prompt on the Windows Server 2025 host to list active connections.
  • Cross-reference the PIDs returned against Task Manager or tasklist /FI "PID eq <pid>" to identify the offending process.
  • Check SQL Server error logs (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for repeated 8407 entries and timestamps to correlate with the connection attempts.

Step 2: Restrict and Validate Endpoint Access

  • Open SQL Server Management Studio (SSMS) and run SELECT * FROM sys.service_broker_endpoints; to confirm the endpoint state is STARTED and the port matches expectations.
  • Use SELECT * FROM sys.dm_broker_connections; to view active Broker connections and spot any unexpected source IP addresses.
  • Create or update a Windows Firewall rule to restrict inbound traffic on the Service Broker port to only trusted SQL Server instances:
  • New-NetFirewallRule -DisplayName "SQLBroker-Restricted" -Direction Inbound -LocalPort 4022 -Protocol TCP -RemoteAddress <TrustedServerIP> -Action Allow
  • Remove any overly permissive “Any-Any” firewall rules previously applied to port 4022.

Step 3: Rebuild or Reset the Service Broker Endpoint

  • In SSMS, drop and recreate the endpoint if corruption is suspected:
  • DROP ENDPOINT [ServiceBrokerEndpoint];
  • CREATE ENDPOINT [ServiceBrokerEndpoint] STATE = STARTED AS TCP (LISTENER_PORT = 4022) FOR SERVICE_BROKER (AUTHENTICATION = WINDOWS, ENCRYPTION = REQUIRED);
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER to apply the new endpoint configuration cleanly.
  • Confirm no legacy load balancer or proxy (e.g., HAProxy, F5) is health-checking port 4022 with plain TCP pings instead of actual TDS packets.

Step 4: Check for Network-Level Interference

  • Verify Jumbo Frames, MTU settings, and NIC offloading features on the Windows Server 2025 host are not fragmenting or corrupting TDS packets:
  • Get-NetAdapterAdvancedProperty -Name "Ethernet" | Where-Object {$_.DisplayName -like "*Offload*"}
  • Temporarily disable TCP Chimney Offload or Receive Side Scaling (RSS) if packet corruption is suspected at the NIC driver level.
  • If using a VPN or VLAN tunnel between distributed Broker instances, confirm MTU consistency end-to-end to prevent silent packet truncation.

Alternative or Verification Steps

  • After applying fixes, run SELECT * FROM sys.transmission_queue; on both sending and receiving databases to confirm no messages are stuck with transmission errors referencing 8407.
  • If the error persists, enable Service Broker trace flags (such as 9950) temporarily and capture a network trace with Wireshark filtered on the Broker port to pinpoint the exact malformed packet source before re-engaging application or network teams.

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

Troubleshooting Guide: SQL Server Error 8408 – “Target service does not support contract”

Why This Error Happens

This error occurs in SQL Server Service Broker when a message is sent to a target service that has not been configured with a contract matching the one specified in the dialog request. It typically results from a mismatch between the CONTRACT defined on the SERVICE and the contract referenced in the BEGIN DIALOG CONVERSATION statement, or from a Service Broker route pointing to a service definition that is outdated or missing on the target database. Corrupted or incomplete Service Broker metadata after a database restore, migration, or manual DDL change can also trigger this mismatch.

Step-by-Step Resolution Guide

Step 1: Verify the Service and Contract Definitions

  • Run SELECT * FROM sys.services; on both the initiator and target databases to confirm the service names and associated contracts.
  • Run SELECT * FROM sys.service_contracts; to check that the contract name referenced in your BEGIN DIALOG statement actually exists on the target.
  • Confirm the contract name is spelled identically (case-sensitive collations can cause silent mismatches).

Step 2: Recreate or Alter the Service to Include the Correct Contract

  • If the contract is missing from the service definition, drop and recreate the service with the correct contract binding:
  • DROP SERVICE [TargetServiceName];
  • CREATE SERVICE [TargetServiceName] ON QUEUE [TargetQueue] ([YourContractName]);
  • Ensure the contract itself was created beforehand using CREATE CONTRACT [YourContractName] ([MessageType] SENT BY INITIATOR);.

Step 3: Validate Service Broker Routes and Endpoints

  • Check sys.routes on both instances to ensure the SERVICE_NAME in the route matches the actual service name exactly, including trailing spaces or casing differences.
  • On Windows Server 2025 / Windows 11 hosts, confirm the Service Broker endpoint is enabled and not blocked by Windows Firewall (default port 4022) using:
  • Get-NetFirewallRule -DisplayName "*SQL Server Broker*"
  • If using cross-database or cross-instance Broker, verify certificates used for Broker security haven’t expired via sys.certificates.

Step 4: Rebuild Broker Metadata if Corruption Is Suspected

  • If the database was recently restored or attached, run ALTER DATABASE [YourDB] SET NEW_BROKER; only if Broker GUID conflicts are confirmed (use with caution, this resets conversation state).
  • Alternatively, use ALTER DATABASE [YourDB] SET ENABLE_BROKER; if Broker was disabled during migration.

Alternative or Verification Steps

  • Send a test message using BEGIN DIALOG CONVERSATION and SEND ON CONVERSATION between the initiator and target service, then check sys.transmission_queue for delivery errors—an empty queue confirms success.
  • If the issue persists, drop and fully recreate the queue, service, and contract chain in the correct dependency order (message type → contract → queue → service) to eliminate any residual metadata corruption.

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

Troubleshooting Guide: SQL Server Error 8406 – Invalid Dialog Lifetime

Why This Error Happens

Error 8406 occurs when a Service Broker dialog conversation is initiated with a LIFETIME parameter that is either NULL or falls outside the acceptable range (typically 1 to 2,147,483,647 seconds). This commonly happens due to a coding defect in a stored procedure or application layer where the lifetime variable is not properly initialized before being passed to the BEGIN DIALOG CONVERSATION statement. It can also surface after a migration to SQL Server 2025 if legacy T-SQL scripts relied on deprecated default behaviors that are no longer supported.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Statement

  • Review the SQL Server error log or Extended Events session to locate the exact BEGIN DIALOG CONVERSATION command that triggered the error.
  • Check the specific stored procedure or application code responsible for initiating the Service Broker conversation.
  • Look specifically for the WITH LIFETIME = clause in the syntax.

Step 2: Correct the Lifetime Variable Declaration

  • Open the identified stored procedure in SQL Server Management Studio (SSMS) for editing.
  • Ensure the variable used for lifetime (e.g., @dialogLifetime) is explicitly declared as an INT and assigned a positive, non-null value.
  • Example fix: SET @dialogLifetime = 86400; (sets lifetime to 24 hours in seconds).
  • Avoid using GETDATE() or other non-integer functions directly in the lifetime parameter.

Step 3: Validate Application Connection Strings

  • If the error originates from a .NET or Java application connecting to Windows Server 2025, check the application’s configuration files (e.g., appsettings.json or web.config).
  • Ensure that any parameters passed from the application layer to the SQL stored procedure are not sending NULL due to a missing default value in the business logic.

Step 4: Redeploy and Restart the Service Broker

  • Save the corrected stored procedure and recompile it using EXEC sp_recompile 'YourProcedureName';.
  • Restart the specific Service Broker queue if it has moved to a disabled state due to repeated errors:
    ALTER QUEUE YourQueueName WITH STATUS = ON;

Alternative or Verification Steps

  • Verification: Run the stored procedure manually in a test environment using SSMS with a hardcoded integer value (e.g., 1000) to confirm the dialog initiates successfully without throwing Error 8406.
  • Alternative: If the issue persists despite code changes, use SQL Server Profiler to trace the exact value being passed in real-time, as the error might be caused by a race condition in multi-threaded application code overwriting the variable before execution.

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

Troubleshooting Guide: SQL Server Error 8404 – Duplicate Service Contract Specification

Why This Error Happens

This error occurs when a Service Broker CREATE SERVICE or CREATE CONTRACT statement references the same service contract name more than once within the same definition. SQL Server’s Service Broker engine requires each contract bound to a service to be unique, so duplicate entries in the T-SQL script, a migration file, or an automated deployment template trigger a validation failure during parsing. This commonly happens after copy-paste errors in DDL scripts, merge conflicts in source-controlled schema files, or when a third-party tool/ORM auto-generates Service Broker definitions without deduplication logic.

Step-by-Step Resolution Guide

Step 1: Locate the Offending T-SQL Script

  • Identify the exact script or stored procedure that issued the CREATE SERVICE statement causing the error.
  • Check SQL Server Error Logs via SQL Server Management Studio (SSMS) > Management > SQL Server Logs, or query sys.messages for Error 8404 context.
  • Note the full contract name reported in the error message (replacing %.*ls with the actual contract name).

Step 2: Inspect and Edit the Service Definition

  • Open the script in SSMS or your deployment tool (e.g., Azure Data Studio, Visual Studio Database Project).
  • Search for all instances of the contract name inside the CREATE SERVICE [service_name] ON QUEUE [queue_name] ([contract_name], [contract_name]) syntax.
  • Remove the duplicate reference so each contract appears only once, for example:
  CREATE SERVICE [MyService]
  ON QUEUE [MyQueue]
  ([MyContract]);
  • If the service already exists with duplicates, drop and recreate it:
  DROP SERVICE [MyService];
  GO
  CREATE SERVICE [MyService]
  ON QUEUE [MyQueue]
  ([MyContract]);

Step 3: Validate Deployment and Automation Scripts

  • If using DACPAC, SSDT, or CI/CD pipelines (Azure DevOps, GitHub Actions) on Windows Server 2025, check the .sql publish scripts under your project’s Schema Objects\Service Broker folder for duplicate contract declarations.
  • Rebuild and republish the DACPAC after removing duplicates to ensure the schema compare does not reintroduce the error.

Step 4: Restart the Affected SQL Service (If Needed)

  • Open services.msc on Windows Server 2025 or Windows 11 and restart the SQL Server (MSSQLSERVER) service only if Service Broker remains in a broken state after the fix.
  • Alternatively, run ALTER SERVICE BROKER commands to reset the broker state without a full restart:
  ALTER DATABASE [YourDB] SET ENABLE_BROKER;

Alternative or Verification Steps

  • Verify the fix by querying sys.services and sys.service_contract_usages to confirm each service-to-contract mapping is unique and the contract count matches expectations.
  • If the error persists in automated deployments, run the script manually in a test database first to isolate whether the duplication originates from the source script or from a templating/ORM tool generating redundant CREATE SERVICE statements.

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

Troubleshooting Guide: SQL Server Error 8405 — Service Broker Queue Rollback Handler Failure

Why This Error Happens

Error 8405 occurs when SQL Server’s Service Broker attempts to roll back a transaction on a queue, but the rollback handler encounters an inconsistency, such as a corrupted internal queue structure or a conflict with concurrent activation procedures. This is often triggered by abrupt service termination, disk I/O failures during a transaction, or insufficient permissions for the Service Broker’s internal system objects to complete the rollback cleanly. In some cases, it stems from a mismatch between the queue’s metadata and the actual message data in sys.transmission_queue.

Step-by-Step Resolution Guide

Step 1: Verify Service Broker Status and Permissions

  • Open SQL Server Management Studio (SSMS) and connect to the instance running on Windows Server 2025.
  • Run the following query to check if Service Broker is enabled on the affected database:
SELECT name, is_broker_enabled FROM sys.databases WHERE name = 'YourDatabaseName';
  • Ensure the service account running SQL Server has CONTROL permission on the Service Broker queue and db_owner rights on the system databases.
  • If permissions are missing, grant them using:
GRANT CONTROL ON SERVICE::[YourServiceName] TO [YourServiceAccount];

Step 2: Inspect and Clear the Transmission Queue

  • Check for stuck or poisoned messages in the transmission queue that may be blocking the rollback process.
SELECT * FROM sys.transmission_queue;
  • If corrupted messages are found, disable and re-enable the broker to force a reset:
ALTER DATABASE YourDatabaseName SET DISABLE_BROKER;
ALTER DATABASE YourDatabaseName SET ENABLE_BROKER;
  • Note: This may require exclusive database access; schedule this during a maintenance window.

Step 3: Check for Activation Procedure Conflicts

  • Navigate to the Activation Stored Procedure associated with the queue and review its error handling logic for unhandled exceptions that might cause repeated rollback attempts.
  • Open Event Viewer on Windows Server 2025 (Windows Logs > Application) and filter for Event ID 8405 to correlate the exact timestamp with any custom logging in the stored procedure.
  • Temporarily disable activation to isolate the issue:
ALTER QUEUE YourQueueName WITH ACTIVATION (STATUS = OFF);

Step 4: Run Database Consistency Checks

  • Execute DBCC CHECKDB to rule out underlying corruption in the system catalog tables that support Service Broker.
DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Repair any reported corruption using the suggested minimal repair level, backing up the database first.

Alternative or Verification Steps

  • To verify the fix, monitor the SQL Server Error Log and Event Viewer for 24-48 hours to confirm Error 8405 does not recur during peak transaction loads.
  • If the error persists, consider restarting the SQL Server Service Broker Manager via the SQL Server Configuration Manager, or as a last resort, detach and re-attach the database to force a full metadata refresh.

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

Troubleshooting Guide: SQL Server Error 8403

Why This Error Happens

Error 8403 occurs when a Service Broker CONVERSATION PRIORITY, CONTRACT, or message type definition references the same message type name more than once within a single CREATE or ALTER statement. This typically results from a scripting error, a faulty migration script, or copy-paste duplication when defining contracts that specify which message types are valid for a conversation. SQL Server’s parser rejects the statement outright because each message type must be uniquely bound within the scope of the object being created, preventing ambiguous routing behavior in the Broker message queue.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Script

  • Locate the exact CREATE CONTRACT or ALTER statement referenced in the error output; the %.*ls placeholder will be substituted with the actual duplicated message type name when the error fires.
  • Open the script in SQL Server Management Studio (SSMS) or Azure Data Studio connected to your Windows Server 2025 instance.
  • Use Ctrl+F to search for every instance of the flagged message type name within the script body.

Step 2: Remove Duplicate Message Type References

  • Review the CONTRACT definition syntax, which typically looks like:
CREATE CONTRACT [MyContract]
([MessageType1] SENT BY INITIATOR,
 [MessageType2] SENT BY TARGET);
  • Delete any repeated line referencing the same message type (e.g., ensure [MessageType1] appears only once regardless of whether it’s listed as SENT BY INITIATOR, SENT BY TARGET, or SENT BY ANY).
  • If the message type genuinely needs to be sent by both initiator and target, use the single SENT BY ANY clause instead of two separate entries.

Step 3: Validate Existing Message Types in the Database

  • Run the following query to audit currently registered message types and check for naming collisions before re-deploying the script:
SELECT name, message_type_id, validation 
FROM sys.service_message_types;
  • Cross-reference this list against your script to confirm you are not accidentally redefining a system-reserved or pre-existing message type under a duplicate alias.

Step 4: Re-deploy the Corrected Script

  • Drop the failed contract object if it was partially created: DROP CONTRACT [MyContract]; (only if applicable).
  • Re-run the corrected CREATE CONTRACT statement in a new query window.
  • Check the Messages tab in SSMS for a “Command(s) completed successfully” confirmation rather than the 8403 error.

Alternative or Verification Steps

  • Verify the fix by querying sys.service_contract_message_usages joined with sys.service_contracts to confirm each message type ID appears only once per contract ID.
  • If the error persists despite a visually clean script, check for hidden whitespace or encoding issues (e.g., BOM characters) in the .sql file by re-typing the contract statement manually in a fresh query window on Windows 11/Server 2025.

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

Troubleshooting Guide: SQL Server Error 8401 – Service Broker Queue Permission Denied

Why This Error Happens

Error 8401 occurs when a Service Broker message attempts to be delivered to a queue, but the target user (identified by the user ID in the error message) lacks the RECEIVE permission on that specific queue object. This typically happens after a queue is newly created without explicit grants, when a user’s permissions were revoked during a security audit, or when the queue’s owner/schema changed without updating associated permissions. It can also surface after a database restore or migration where permission mappings did not transfer correctly between the source and destination instances.

Step-by-Step Resolution Guide

Step 1: Identify the Target User and Queue

  • Parse the error message to extract the User ID and Database ID values returned in the text (e.g., %i in database ID %i).
  • Run the following query against the affected database to resolve the IDs to readable names:
SELECT name FROM sys.database_principals WHERE principal_id = <UserID>;
SELECT name FROM sys.databases WHERE database_id = <DatabaseID>;
  • Note the exact queue name referenced in the %.*ls portion of the error for use in the next step.

Step 2: Grant RECEIVE Permission on the Queue

  • Open SQL Server Management Studio (SSMS) 2025 or a query window connected to the affected instance.
  • Execute the GRANT statement using the resolved user and queue names:
USE [YourDatabaseName];
GRANT RECEIVE ON QueueName TO [TargetUserName];
  • If the queue resides in a non-default schema, fully qualify the object name (e.g., SchemaName.QueueName).

Step 3: Verify Service Broker and Schema Ownership

  • Confirm Service Broker is enabled on the database:
SELECT is_broker_enabled FROM sys.databases WHERE name = 'YourDatabaseName';
  • If disabled, enable it with:
ALTER DATABASE [YourDatabaseName] SET ENABLE_BROKER;
  • Check that the queue’s schema owner has not changed unexpectedly, as orphaned schema ownership can silently strip effective permissions even after granting RECEIVE.

Step 4: Restart the SQL Server Service (If Permissions Do Not Take Effect)

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Locate SQL Server (MSSQLSERVER) or the named instance service.
  • Right-click and select Restart to force the Service Broker engine to re-cache security metadata.

Alternative or Verification Steps

  • Verify the fix by re-sending a test message to the queue using SEND ON CONVERSATION and confirming it is received without triggering Error 8401 in the SQL Server Error Log.
  • If the issue persists, check for conflicting Deny permissions on the user or any role they belong to, since an explicit DENY RECEIVE will override the GRANT statement applied in Step 2.

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

Troubleshooting Guide: SQL Server Error 8402 – Invalid Data Type in Statement

Why This Error Happens

Error 8402 occurs when a Transact-SQL statement references a column, variable, or parameter with a data type that is not supported by the specific clause or operation being executed, such as using text, ntext, image, or xml types in contexts that require simpler scalar types. This is commonly triggered when legacy data types are used in newer T-SQL constructs like MERGE, table-valued parameters, or certain system procedures that explicitly restrict allowed types. It can also surface after a database migration or compatibility level upgrade to SQL Server 2025, where deprecated types that worked under older compatibility levels are no longer tolerated in specific statements.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Statement and Column

  • Review the full error message to capture the exact column name and statement type referenced in the ‘%S_MSG’ placeholders.
  • Run sp_help 'YourTableName' in SQL Server Management Studio (SSMS) to inspect the current data type of the flagged column.
  • Check if the column uses a deprecated type like text, ntext, image, or timestamp instead of modern equivalents.

Step 2: Convert the Column to a Supported Data Type

  • Alter the column to use a supported type, for example: ALTER TABLE YourTable ALTER COLUMN YourColumn VARCHAR(MAX);
  • For text/ntext/image types, migrate to VARCHAR(MAX), NVARCHAR(MAX), or VARBINARY(MAX) respectively.
  • If the column is used in a MERGE statement, ensure it is not a computed column with an unsupported base type.

Step 3: Check Database Compatibility Level

  • Open SSMS, right-click the database, select Properties, then navigate to the Options page.
  • Confirm the Compatibility Level is set to 170 (SQL Server 2025) under ALTER DATABASE YourDB SET COMPATIBILITY_LEVEL = 170;
  • Lower compatibility levels can mask or alter how certain data type restrictions are enforced, so ensure consistency with the engine version.

Step 4: Review Stored Procedures and Table-Valued Parameters

  • If the error originates from a table-valued parameter (TVP), run sp_help 'YourTVPTypeName' to check the column definitions inside the type.
  • Recreate the TVP type with supported data types using CREATE TYPE YourTVPTypeName AS TABLE (Column1 INT, Column2 NVARCHAR(100));
  • Update any stored procedures or application code referencing the old TVP structure to match the corrected schema.

Step 5: Apply Latest Cumulative Update

  • On Windows Server 2025 or Windows 11, open PowerShell as Administrator and check your current SQL Server build with SELECT @@VERSION;
  • Download and install the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Update Catalog to resolve any known data type validation bugs.
  • Restart the SQL Server service via services.msc or Restart-Service -Name 'MSSQLSERVER' after installation.

Alternative or Verification Steps

  • Re-run the original query or application transaction that triggered Error 8402 and confirm it completes without raising the same error in SSMS or the Windows Event Viewer.
  • If the issue persists, use sys.columns and sys.types system views to cross-reference every column involved in the statement and confirm none still reference deprecated or unsupported data types.

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

Troubleshooting Guide: SQL Server Error 8399 — Deprecated Feature Warning

Why This Error Happens

Error 8399 is raised as an informational/warning-level message when SQL Server 2025 detects that a T-SQL statement, stored procedure, or application is invoking a feature that has been marked as deprecated and scheduled for removal in a future release. This typically occurs because legacy code — often carried forward from SQL Server 2017/2019/2022 compatibility levels — still references syntax, system views, or configuration options that Microsoft has flagged for discontinuation. The root cause is not a system failure but rather technical debt in the codebase that has not been updated to align with current SQL Server best practices.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Deprecated Feature Triggering the Warning

  • Open SQL Server Management Studio (SSMS) and run the query that produces the error to capture the full message, since %ls is replaced with the actual feature name at runtime.
  • Cross-reference the feature name against the deprecated features list in SQL Server Books Online or the official Microsoft Learn documentation for SQL Server 2025.
  • Use the following query to check usage counters tracked by SQL Server itself:
  SELECT * FROM sys.dm_os_performance_counters
  WHERE object_name LIKE '%Deprecated Features%';

Step 2: Locate and Audit the Source Code

  • Search stored procedures, views, and functions for the deprecated syntax using:
  SELECT OBJECT_NAME(object_id), definition
  FROM sys.sql_modules
  WHERE definition LIKE '%<deprecated_keyword>%';
  • Check linked applications, SSIS packages, and ORM-generated queries (e.g., Entity Framework) for the same pattern, since deprecated calls often originate outside the database layer.
  • Review any database compatibility level settings via:
  SELECT name, compatibility_level FROM sys.databases;

Step 3: Replace the Deprecated Feature with the Supported Alternative

  • Consult the Microsoft “Deprecated Database Engine Features” documentation to find the recommended replacement syntax or object.
  • Update stored procedures and application queries to use the new supported method (e.g., replacing sp_ legacy system procedures with catalog views, or replacing SET ROWCOUNT with TOP clauses).
  • Test changes in a staging/UAT environment running Windows Server 2025 before deploying to production.

Step 4: Suppress Non-Critical Warnings (Temporary Workaround Only)

  • If immediate code remediation isn’t feasible, use trace flag 3609 cautiously or adjust the client application’s error-handling logic to log Severity 10 informational messages separately rather than treating them as failures.
  • Document this as technical debt and schedule a follow-up sprint for proper remediation, since suppressing the warning does not stop the feature from being removed later.

Alternative or Verification Steps

  • Re-run the original query/procedure after code updates and confirm Error 8399 no longer appears in the SSMS Messages tab or the SQL Server Error Log (Management > SQL Server Logs).
  • As an alternative, enable Extended Events with the deprecation_announcement event to continuously monitor the instance for any remaining deprecated feature calls across all databases.

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

Why This Error Happens

This error occurs because a Transact-SQL query references a column using a deprecated “server.database.schema.column” or “database.schema.column” naming convention instead of the standard two-part format (schema.table). SQL Server 2025 flags this as a deprecation warning because multi-part (three or four-part) column name resolution is slated for removal in a future release. It typically surfaces in legacy stored procedures, views, or applications that were migrated from older SQL Server versions without updating query syntax.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Object

  • Run SELECT * FROM sys.dm_os_ring_buffers or check the SQL Server Error Log via EXEC sp_readerrorlog 0, 1, '8398'; to locate the exact statement triggering the warning.
  • Use SQL Server Profiler or Extended Events (xEvents) on Windows Server 2025 to capture the exact query text in real time.
  • Cross-reference the flagged object in sys.sql_modules to find stored procedures or views using three/four-part names.

Step 2: Rewrite the Query to Two-Part Naming

  • Open the affected .sql file or stored procedure in SQL Server Management Studio (SSMS) 21 (compatible with SQL Server 2025).
  • Replace references like ServerName.DatabaseName.dbo.TableName.ColumnName with standard TableAlias.ColumnName syntax.
  • Example fix: Change SELECT MyDB.dbo.Orders.OrderID FROM MyDB.dbo.Orders to SELECT O.OrderID FROM dbo.Orders AS O.

Step 3: Update Linked Server and Application Connection Strings

  • Navigate to Object Explorer > Server Objects > Linked Servers in SSMS and confirm queries against linked servers use OPENQUERY() instead of inline four-part names.
  • If the issue originates from an application (e.g., a .NET app on Windows 11), check the connection string and ORM-generated SQL (Entity Framework, Dapper) for auto-generated multi-part references.
  • Update the application’s data access layer code and redeploy.

Step 4: Apply Compatibility Level Review

  • In SSMS, right-click the database > Properties > Options, and check the “Compatibility Level” field.
  • Ensure it is set to 170 (SQL Server 2025) so deprecation warnings are accurately surfaced during testing rather than hidden under legacy behavior.
  • Re-run the application test suite to confirm no additional queries trigger Error 8398.

Alternative or Verification Steps

  • Verify the fix by re-executing the corrected query in SSMS and confirming Error 8398 no longer appears in the Messages tab or Error Log.
  • If rewriting all instances is not immediately feasible, use Extended Events to monitor and log occurrences of Error 8398 (sqlserver.error_reported filtered by error_number = 8398) as a temporary mitigation while scheduling a full code review.

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

Troubleshooting Guide: SQL Server Error 8396 — Deprecated Feature Warning

Why This Error Happens

Error 8396 is a deprecation warning raised by the SQL Server Database Engine when a query, stored procedure, or application references a syntax element, system object, or feature flagged for removal in a future release. This typically occurs because legacy T-SQL code (written for older compatibility levels) still invokes deprecated constructs such as old-style joins, certain system tables, SQL-DMO objects, or legacy configuration options. The warning itself does not break functionality immediately, but it indicates that the underlying feature will eventually be removed, which can cause application failures after a future SQL Server upgrade.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Deprecated Feature Triggering the Warning

  • Check the SQL Server Error Log or Application Event Viewer for the full message text, since %ls is replaced with the actual feature name at runtime.
  • Run the following query to capture deprecation events via Extended Events or the deprecated features counter:
  SELECT * FROM sys.dm_os_performance_counters 
  WHERE object_name LIKE '%Deprecated Features%';
  • Cross-reference the identified feature name against Microsoft’s official “Deprecated Database Engine Features” documentation for SQL Server 2025.

Step 2: Locate and Audit the Source Code Using the Feature

  • Search stored procedures, views, functions, and application connection strings for the deprecated syntax using:
  SELECT OBJECT_NAME(object_id), definition 
  FROM sys.sql_modules 
  WHERE definition LIKE '%<deprecated_keyword>%';
  • Use SQL Server Management Studio (SSMS) 21’s built-in “Database Engine Tuning Advisor” or the SQL Server Upgrade Advisor tool to scan the entire database for deprecated object usage.
  • Document every object and script referencing the flagged feature before making changes.

Step 3: Refactor Code to Use the Supported Replacement

  • Replace deprecated syntax with the modern equivalent recommended by Microsoft (for example, replacing old-style *= outer joins with ANSI LEFT JOIN / RIGHT JOIN syntax).
  • Update any linked application code, ORM mappings, or middleware (e.g., .NET Entity Framework models) referencing the old feature.
  • Test the updated queries in a non-production environment running the same Database Compatibility Level as production (check via sys.databases.compatibility_level).

Step 4: Adjust Database Compatibility Level (If Immediate Refactor Isn’t Possible)

  • As a temporary mitigation, you can lower the compatibility level to suppress certain deprecation paths while refactoring is completed:
  ALTER DATABASE [YourDatabaseName] 
  SET COMPATIBILITY_LEVEL = 160;
  • Note: This is a stop-gap measure only — it does not fix the root cause and should be reverted once code is updated.

Step 5: Deploy and Monitor

  • Push the corrected scripts to a staging environment on Windows Server 2025, then validate against the SQL Server 2025 error log for recurrence of Error 8396.
  • Enable SQL Server Audit or Extended Events tracing on the “deprecationannouncement” and “deprecationfinal_support” event classes to catch any missed instances.

Alternative or Verification Steps

  • Verify the fix by re-running the workload and confirming Error 8396 no longer appears in sys.dm_os_performance_counters or the SQL Server Error Log after 24–48 hours of normal operation.
  • If refactoring is not immediately feasible, use SQL Server Upgrade Advisor to generate a full compatibility report and schedule remediation in your next maintenance window rather than ignoring the warning long-term.

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

Troubleshooting Guide: SQL Server Error 8397

Why This Error Happens

Error 8397 in Microsoft SQL Server typically occurs when the TEXT, NTEXT, or IMAGE data type pointer being referenced is invalid, stale, or has been deallocated before the operation completed. This often happens due to a mismatch between the in-memory text pointer and the actual data page on disk, frequently caused by corrupted system catalog references, interrupted transactions, or improper use of READTEXT/WRITETEXT/UPDATETEXT operations. On Windows Server 2025 and Windows 11 hosts, this can also be triggered by file system-level corruption affecting the underlying MDF/NDF data files.

Step-by-Step Resolution Guide

Step 1: Verify the Text Pointer Validity

  • Run DBCC CHECKDB on the affected database to identify corruption in TEXT/NTEXT/IMAGE columns.
  • Check if the text pointer was obtained using TEXTPTR() and confirm it hasn’t expired due to a committed or rolled-back transaction.
  • Use the command: SELECT TEXTPTR(column_name) FROM table_name WHERE condition; to validate pointer generation.

Step 2: Review Transaction Isolation and Timing

  • Ensure that TEXT pointer operations (READTEXT, WRITETEXT, UPDATETEXT) occur within the same transaction scope where the pointer was generated.
  • Avoid holding text pointers across batches or application reconnects.
  • Check application connection pooling settings in IIS or your .NET connection string, as pooled connections on Windows Server 2025 may silently reset sessions.

Step 3: Repair Database Corruption

  • Place the database in single-user mode: ALTER DATABASE YourDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run DBCC CHECKDB (YourDB, REPAIR_ALLOW_DATA_LOSS) only after taking a full backup.
  • Restore the database from the most recent clean backup if repair fails, using SQL Server Management Studio or RESTORE DATABASE YourDB FROM DISK = 'C:\Backups\YourDB.bak' WITH RECOVERY;

Step 4: Update SQL Server and Verify File System Health

  • Apply the latest Cumulative Update for SQL Server 2025 via Microsoft Update or SSMS Setup.
  • Run chkdsk C: /f /r on Windows Server 2025 to rule out underlying disk corruption affecting the data files located typically at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.

Alternative or Verification Steps

  • Re-run the original query or application process that triggered Error 8397 and confirm no exception is thrown in SQL Server Error Logs (Management > SQL Server Logs in SSMS).
  • If the issue persists, migrate large object (LOB) columns from deprecated TEXT/NTEXT/IMAGE types to modern VARCHAR(MAX), NVARCHAR(MAX), or VARBINARY(MAX) types, which eliminates legacy text pointer dependencies entirely.

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

Troubleshooting Guide: SQL Server Error 8394 – Deprecated Index Option Syntax

Why This Error Happens

This warning occurs because the index creation or modification statement uses an older, legacy syntax structure for specifying index options (such as placing options like PAD_INDEX, FILLFACTOR, or IGNORE_DUP_KEY outside the standard WITH (...) clause format). SQL Server 2025 continues to parse this older structure for backward compatibility, but it flags it because the legacy parser path is scheduled for removal in a future release. This typically surfaces in environments where scripts were written for very old SQL Server versions (pre-2005 syntax conventions) and have been carried forward through migrations without modernization.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Statements

  • Check the SQL Server Error Log or Extended Events session capturing Error 8394 to locate the exact session and query text.
  • Run the following query against sys.dm_exec_query_stats combined with sys.dm_exec_sql_text to find recent CREATE INDEX or ALTER INDEX statements:
  SELECT st.text, qs.last_execution_time
  FROM sys.dm_exec_query_stats qs
  CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
  WHERE st.text LIKE '%INDEX%'
  ORDER BY qs.last_execution_time DESC;
  • Also search deployment scripts, SSDT projects, and stored procedures under your source control repository for legacy index syntax patterns like CREATE INDEX ... ON table (col) WITH FILLFACTOR = 80 (without parentheses around options).

Step 2: Rewrite Index Definitions Using Modern Syntax

  • Convert any legacy option declarations into the standardized WITH (...) clause format.
  • Example of deprecated syntax to avoid:
  CREATE INDEX IX_Test ON dbo.MyTable (ColumnA) WITH FILLFACTOR = 80, PAD_INDEX
  • Replace it with the supported modern structure:
  CREATE INDEX IX_Test ON dbo.MyTable (ColumnA)
  WITH (FILLFACTOR = 80, PAD_INDEX = ON);
  • Update all affected stored procedures, views, and deployment/migration scripts (e.g., DACPAC, Flyway, or SSDT publish profiles) to match this corrected structure.

Step 3: Validate Database Compatibility Level

  • Open SQL Server Management Studio (SSMS) and run:
  SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • If the compatibility level is set below 160 (SQL Server 2022) or the new 2025 baseline, consider updating it via:
  ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 170;
  • Test thoroughly in a staging environment first, as compatibility level changes can affect query plan behavior across the entire database.

Step 4: Deploy and Monitor

  • Push the corrected scripts to your Windows Server 2025 or Windows 11 development/test SQL instance.
  • Re-run the original workload or deployment pipeline and monitor the SQL Server Error Log (Program Files\Microsoft SQL Server\MSSQLXX.MSSQLSERVER\MSSQL\Log\ERRORLOG) to confirm Error 8394 no longer appears.

Alternative or Verification Steps

  • Enable an Extended Events session filtering on error_reported with error_number = 8394 to confirm no new instances are logged after remediation.
  • If immediate full remediation isn’t feasible, use SQL Server Deprecated Features Extended Events (deprecation_announcement event) to track and schedule a phased cleanup of legacy syntax across all databases before the feature is fully removed in a future release.

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

Troubleshooting Guide: SQL Server Error 8391 — Deprecated 2-Part Name Syntax in DROP INDEX

Why This Error Happens

This error occurs because SQL Server 2025 has deprecated the legacy 2-part naming convention (index_name.table_name) for the DROP INDEX statement. The database engine’s parser now expects fully qualified 3-part table or view names combined with the 1-part index name, and any script, stored procedure, or application still using the old syntax will trigger this warning or fail outright depending on compatibility level. This typically surfaces after an in-place upgrade or migration from an older SQL Server version where legacy T-SQL scripts were never modernized.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Scripts

  • Search all stored procedures, views, functions, and maintenance scripts for DROP INDEX statements using the pattern DROP INDEX <index_name> ON <table_name> is fine, but flag any using DROP INDEX <index_name>.<table_name>.
  • Run the following query to locate objects referencing DROP INDEX across your database:
SELECT OBJECT_NAME(object_id) AS ObjectName, definition
FROM sys.sql_modules
WHERE definition LIKE '%DROP INDEX%';
  • Export results to a text file for review and prioritize objects executed frequently in production jobs.

Step 2: Rewrite Using New-Style 3-Part Syntax

  • Convert every instance from the deprecated format to the required structure:
-- Old (deprecated) syntax
DROP INDEX IX_Orders_CustomerID ON Orders

-- New required syntax
DROP INDEX IX_Orders_CustomerID ON dbo.Orders
  • Ensure the table/view reference includes at minimum the schema name (2-part minimum) or full database.schema.object (3-part) to satisfy the parser.
  • Update any dynamic SQL strings in application code (C#, PowerShell, or SSIS packages) that generate DROP INDEX commands on the fly.

Step 3: Update SQL Server Agent Jobs and Maintenance Plans

  • Open SQL Server Agent in SSMS and inspect all job steps under Jobs > [JobName] > Steps for embedded T-SQL containing DROP INDEX.
  • Check maintenance plans created via the Maintenance Plan Wizard, specifically the “Rebuild Index” or “Reorganize Index” tasks, as these sometimes generate legacy syntax internally in custom scripts.
  • Redeploy updated scripts and re-enable the job schedule once corrected.

Step 4: Adjust Database Compatibility Level (Temporary Workaround)

  • If immediate code remediation isn’t feasible, check the current compatibility level:
SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • Note that lowering compatibility level is only a short-term buffer and does not guarantee the old syntax will be supported in future cumulative updates — treat this as a stopgap, not a permanent fix.

Alternative or Verification Steps

  • Re-run the corrected DROP INDEX statements manually in SSMS against a test database and confirm no Error 8391 or deprecation warning appears in the Messages tab.
  • Enable the Deprecation Extended Events session (sys.dm_os_performance_counters or trace_event sqlserver.deprecation_announcement) to monitor for any remaining legacy syntax usage across all databases on the instance.

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

Why This Error Happens

This warning (Error 8393) is triggered when a CREATE TABLE or ALTER TABLE statement defines a column using the timestamp (now rowversion) datatype without explicitly assigning it a column name. SQL Server has historically allowed an unnamed timestamp column to auto-generate its name, but this legacy behavior is deprecated and flagged every time the Database Engine parses such a statement. The root cause is almost always legacy T-SQL scripts, ORM-generated migrations, or third-party vendor schemas that were written before Microsoft began enforcing explicit column naming conventions.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Script

  • Search your deployment scripts, stored procedures, and ORM migration files (Entity Framework, Dapper, etc.) for the keyword timestamp used as a datatype.
  • Run the following query against your database to locate existing unnamed timestamp columns:
  SELECT t.name AS TableName, c.name AS ColumnName
  FROM sys.columns c
  JOIN sys.types ty ON c.user_type_id = ty.user_type_id
  JOIN sys.tables t ON c.object_id = t.object_id
  WHERE ty.name = 'timestamp';

Step 2: Rewrite the Schema Definition with Explicit Column Names

  • Replace any instance of a bare timestamp declaration with a named column using the modern rowversion keyword.
  • Example of the deprecated syntax:
  CREATE TABLE Orders (OrderID INT, timestamp);
  • Corrected syntax:
  CREATE TABLE Orders (OrderID INT, RowVer rowversion NOT NULL);

Step 3: Update Application and ORM Mapping Files

  • On Windows Server 2025, open your deployment pipeline (SSDT project, DACPAC, or Flyway/Liquibase migration folder) and apply the renamed column globally.
  • Update any Entity Framework model classes ([Timestamp] attribute mappings) to reference the new explicit column name (RowVer) instead of relying on convention-based binding.
  • Redeploy the schema change using SQL Server Management Studio (SSMS) 21 or sqlcmd from an elevated PowerShell session on Windows 11/Server 2025.

Step 4: Suppress or Monitor the Deprecation Warning (Temporary Workaround)

  • If immediate code changes aren’t feasible, use SQL Server’s Extended Events session to track deprecation announcements without halting builds:
  CREATE EVENT SESSION DeprecationTrack
  ON SERVER
  ADD EVENT sqlserver.deprecation_announcement
  ADD TARGET package0.event_file(SET filename='C:\SQLLogs\DeprecationTrack.xel');
  GO
  ALTER EVENT SESSION DeprecationTrack ON SERVER STATE = START;
  • Treat this only as a monitoring bridge, not a permanent fix, since the feature will be fully removed in a future release.

Alternative or Verification Steps

  • Re-run the sys.columns query from Step 1 after deployment to confirm zero rows are returned, meaning no unnamed timestamp columns remain.
  • Check SQL Server Error Log (via SSMS → Management → SQL Server Logs) or Windows Event Viewer under Applications and Services Logs > MSSQLSERVER to confirm Event ID 8393 no longer appears after the next schema compile or application restart.

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

Troubleshooting Guide: SQL Server Error 8390 – Deprecated ‘::’ Function Calling Syntax

Why This Error Happens

This error occurs because SQL Server 2025 continues its deprecation path for the legacy ::function_name() calling convention used to invoke system/meta-data functions, which was marked deprecated in earlier versions and is now flagged more aggressively via Error 8390. The root cause is almost always legacy T-SQL code, stored procedures, views, or application-generated queries that still reference built-in functions using the old ::fn_helper() style instead of the fully schema-qualified sys.fn_helper() syntax. This is not a permissions or connectivity issue — it is purely a backward-compatibility warning that signals code will break once the syntax is fully removed in a future SQL Server release.

Step-by-Step Resolution Guide

Step 1: Identify All Instances of the Deprecated Syntax

  • Query the SQL Server error log or use Extended Events to capture when Error 8390 fires, since it’s often logged as a warning rather than a hard failure.
  • Search your codebase (stored procedures, functions, views, triggers, SSIS packages, and application connection strings) for the pattern :: immediately preceding a function name, e.g., ::fn_sqlvarbasetostr().
  • Use a script against sys.sql_modules to scan for the literal string '::' combined with common system function names like fn_trace_gettable, fn_virtualfilestats, or fn_sqlvarbasetostr.

Step 2: Replace ‘::’ Syntax with ‘sys.’ Schema-Qualified Calls

  • Edit each identified object and change the calling convention from ::function_name(args) to sys.function_name(args).
  • Example fix: change SELECT * FROM ::fn_helpcollations() to SELECT * FROM sys.fn_helpcollations().
  • Re-deploy or re-compile the modified stored procedures, views, and functions in a test environment first.

Step 3: Update Database Compatibility Level and Validate

  • Confirm the database compatibility level under Database Properties > Options > Compatibility Level in SQL Server Management Studio (SSMS), or run ALTER DATABASE [YourDB] SET COMPATIBILITY_LEVEL = 170; for SQL Server 2025 alignment.
  • Re-run the previously flagged queries/procedures to confirm Error 8390 no longer appears in the output or logs.
  • Check any third-party tools, ORM-generated SQL, or legacy linked-server queries that might still inject the old syntax dynamically.

Step 4: Audit and Patch Application-Level Code

  • Review application source code (C#, Java, Python, etc.) for embedded raw SQL strings containing :: function calls.
  • Update deployment scripts, Entity Framework migrations, or Liquibase/Flyway change sets that may regenerate the deprecated syntax on each release.
  • Push corrected code through your CI/CD pipeline and run integration tests against a staging SQL Server 2025 instance.

Alternative or Verification Steps

  • Enable SQL Server’s Deprecation Features Extended Event (sqlserver.deprecation_announcement) and monitor for any residual triggers of Error 8390 over a 24–48 hour production-like workload.
  • If immediate code remediation isn’t feasible, use sp_configure with trace flags only as a temporary stopgap for monitoring, but note that suppressing the warning does not prevent future removal — full syntax migration to sys. is the only permanent fix.

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

Troubleshooting Guide: SQL Server Error 8389 — Deprecated ALL Permission Warning

Why This Error Happens

Error 8389 is raised because the ALL permission keyword (used in legacy GRANT, DENY, or REVOKE statements) has been marked as deprecated in SQL Server 2025. This is not a failure of a security mechanism but a compatibility warning triggered when SQL Server parses a T-SQL script, stored procedure, or application login script that still uses the broad ALL permission syntax instead of granular, named permissions. The engine flags this to alert administrators that future versions of SQL Server will drop support for ALL entirely, which could break permission assignments during an upgrade if not addressed now.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the Deprecated Syntax

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio connected to your Windows Server 2025 instance.
  • Run the following query to check the deprecation log via Extended Events or the default trace:
  SELECT * FROM sys.fn_trace_gettable(
      (SELECT TOP 1 path FROM sys.traces WHERE is_default = 1), DEFAULT)
  WHERE EventClass = 188; -- Deprecation Announcement
  • Alternatively, search application source code, SSIS packages, and stored procedures for the string GRANT ALL, DENY ALL, or REVOKE ALL.

Step 2: Replace ALL with Explicit Permissions

  • Identify exactly which permissions the application or user actually needs (e.g., SELECT, INSERT, UPDATE, DELETE, EXECUTE).
  • Rewrite the permission statement explicitly. For example, replace:
  GRANT ALL ON dbo.Orders TO AppUser;

with:

  GRANT SELECT, INSERT, UPDATE, DELETE ON dbo.Orders TO AppUser;
  • Update any deployment scripts, DACPAC definitions, or CI/CD pipeline SQL files that reference ALL.

Step 3: Audit Server and Database Roles

  • Use sys.database_permissions and sys.server_permissions to check for any role or login still relying on the ALL keyword:
  SELECT * FROM sys.database_permissions WHERE permission_name = 'ALL';
  • Reassign affected logins to built-in fixed database roles (e.g., db_datareader, db_datawriter) or custom roles built from granular permissions instead of using ALL.

Step 4: Test in a Non-Production Environment

  • Deploy the updated scripts to a staging SQL Server 2025 instance on Windows 11 or Windows Server 2025.
  • Run application integration tests to confirm no functionality breaks due to the permission granularity change.
  • Monitor the SQL Server error log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for recurrence of Error 8389.

Alternative or Verification Steps

  • Verify the fix by re-running the deprecated feature usage query (SELECT * FROM sys.dm_os_performance_counters WHERE counter_name = 'Usage' filtered for deprecated features) and confirming no new entries appear for ALL permission.
  • If immediate code changes aren’t feasible, suppress the warning temporarily by filtering Error 8389 from alerting systems, but schedule remediation before upgrading to the next SQL Server major version, since the permission will be fully removed.

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

Troubleshooting Guide: SQL Server Error 8387 – Table Hints on Views Referencing Multi-Statement TVFs

Why This Error Happens

This warning occurs because a query applies table hints (such as NOLOCK or READUNCOMMITTED) directly to a view, but that view internally references a multi-statement table-valued function (TVF). SQL Server has historically allowed this hint to “pass through” indirectly to the underlying TVF call, but this behavior is deprecated and will be removed in a future version, as Multi-Statement TVFs do not support the same locking/hinting semantics as standard tables. Microsoft SQL Server 2025 now flags this syntax with Error 8387 to force developers to refactor queries before the indirect hint application is permanently removed.

Step-by-Step Resolution Guide

Step 1: Identify the Offending View and Query

  • Run the failing query in SQL Server Management Studio (SSMS) and check the Messages tab for the specific view name referenced in the Error 8387 text.
  • Use sys.sql_expression_dependencies to locate which stored procedures or application queries reference this specific view.
  • Confirm the view’s definition using sp_helptext 'ViewName' to verify it wraps a multi-statement TVF (defined with BEGIN...END and a RETURNS @table TABLE).

Step 2: Remove the Hint from the View Reference

  • Edit the T-SQL query or stored procedure causing the error.
  • Delete the table hint (e.g., WITH (NOLOCK)) immediately following the view name in the FROM clause.
  • Example change: Convert FROM dbo.MyView WITH (NOLOCK) to FROM dbo.MyView.

Step 3: Refactor the Underlying Function (Recommended Fix)

  • Since Multi-Statement TVFs ignore most isolation-level hints anyway, consider converting the Multi-Statement TVF into an Inline Table-Valued Function (iTVF) if the logic is simple enough.
  • Inline TVFs act like parameterized views and fully support hint pass-through, resolving the deprecation warning permanently.
  • Update the view or query to reference the new Inline TVF directly.

Step 4: Adjust Transaction Isolation Levels Instead

  • If the hint was being used to prevent locking issues, remove the specific table hint and set the isolation level for the entire session instead.
  • Add this command at the top of the stored procedure: SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
  • This achieves the same uncommitted-read behavior without triggering the deprecated hint-on-view syntax.

Alternative or Verification Steps

  • Verify the Fix: Re-run the query in SSMS; the Error 8387 message should no longer appear in the Messages pane, and the query should execute without warnings.
  • Alternative Check: Enable SQL Server Profiler or Extended Events to trace for Error/Warning 8387 across your production environment to catch any other legacy stored procedures that might trigger this issue during peak load.

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

Troubleshooting Guide: SQL Server Error 8388 — “Data Access from Triggers” Deprecation Warning

Why This Error Happens

This warning is raised because the trigger in question is returning result sets directly to the calling application, a legacy feature historically enabled through the RETURN DATA behavior of sp_dboption or the disallow results from triggers server configuration. Microsoft has flagged this functionality as deprecated since SQL Server 2005, and in SQL Server 2025, the server configuration enforcing this restriction is now active by default. Essentially, the code is relying on an old T-SQL pattern (using SELECT statements inside a trigger body without suppressing output) that conflicts with modern database engine standards.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Trigger

  • Open SQL Server Management Studio (SSMS) and connect to your Windows Server 2025 instance.
  • Run the following query to search system views for trigger definitions containing SELECT statements that are not assigned to a variable:
SELECT OBJECT_NAME(object_id) AS TriggerName, definition 
FROM sys.sql_modules 
WHERE definition LIKE '%SELECT%' AND object_id IN (SELECT object_id FROM sys.triggers);
  • Note the specific database and trigger name causing the Error 8388 log entry.

Step 2: Modify the Trigger Code

  • Locate the SELECT statement inside the identified trigger that is causing the implicit result set.
  • Refactor the code to use SET NOCOUNT ON at the beginning of the trigger to suppress row-count messages, which are often mistaken for this issue.
  • If the trigger is intentionally returning data to the client (bad practice), move that logic out of the trigger. Replace it with a stored procedure call or application-side logic instead.
  • Ensure no stray SELECT * FROM Inserted or SELECT * FROM Deleted statements exist without a specific INSERT INTO or variable assignment target.

Step 3: Verify Server Configuration

  • Open a new query window and check the current server configuration using:
EXEC sp_configure 'disallow results from triggers';
  • If the run_value is set to 0, change it to 1 to strictly enforce the new standard and immediately expose any other hidden instances of this issue:
EXEC sp_configure 'disallow results from triggers', 1;
RECONFIGURE;

Step 4: Restart the SQL Server Service

  • Open the Services app on Windows Server 2025 (services.msc).
  • Locate SQL Server (MSSQLSERVER) or your specific named instance.
  • Right-click and select Restart to ensure the RECONFIGURE command takes full effect across all active connections.

Alternative or Verification Steps

  • Verification: Re-run the application process that triggered the error and check the SQL Server Error Log (via SSMS > Management > SQL Server Logs) to confirm Error 8388 no longer appears.
  • Alternative: If refactoring the trigger is not immediately possible, use an INSTEAD OF trigger with explicit INSERT INTO @TableVariable logic rather than direct SELECT output to bypass the deprecated behavior while maintaining functionality.

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

Troubleshooting Guide: SQL Server Error 8386 – Deprecated Table Hint on INSERT Target

Why This Error Happens

This warning occurs because the T-SQL statement applies a table hint (such as TABLOCK, HOLDLOCK, READPAST, UPDLOCK, etc.) directly to the target table of an INSERT statement, a syntax pattern that Microsoft has marked as deprecated starting in recent SQL Server versions. SQL Server 2025 continues to honor the hint for backward compatibility but raises Error 8386 because this functionality may be removed entirely in a future release. The root cause is almost always legacy application code, stored procedures, or ORM-generated queries that were written against older SQL Server versions where this hint placement was standard practice.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Stored Procedure

  • Check the SQL Server Error Log or Extended Events session for the full text of Error 8386, which includes the specific hint name (e.g., TABLOCK).
  • Run the following query to search for recently modified procedures that may contain INSERT INTO ... WITH (:
SELECT OBJECT_NAME(object_id), definition
FROM sys.sql_modules
WHERE definition LIKE '%INSERT%WITH%(%';
  • Cross-reference results with your application’s data access layer or ORM-generated SQL if no stored procedure matches.

Step 2: Modify the INSERT Statement Syntax

  • Remove the hint from the target table clause and relocate it (if still needed) using the OPTION clause at the end of the statement, or eliminate it entirely if it is no longer functionally necessary.
  • Example of the deprecated syntax to fix:
INSERT INTO dbo.SalesData WITH (TABLOCK) (OrderID, Amount)
SELECT OrderID, Amount FROM Staging.OrdersTemp;
  • Corrected syntax (hint removed, since TABLOCK on INSERT is often unnecessary under modern locking):
INSERT INTO dbo.SalesData (OrderID, Amount)
SELECT OrderID, Amount FROM Staging.OrdersTemp;

Step 3: Update Application and Deployment Scripts

  • If the hint originates from an ORM (Entity Framework, Hibernate, etc.) or a third-party tool, check for a configuration flag or raw SQL override generating this pattern.
  • Update deployment scripts, DACPAC files, or SSDT projects in Visual Studio/Azure Data Studio to reflect the corrected syntax before redeploying to Windows Server 2025 instances.
  • Re-run sqlpackage.exe or your CI/CD pipeline to push the corrected schema objects.

Step 4: Enable Trace Flag for Early Detection (Optional)

  • Enable Trace Flag 7412 (Lightweight Query Profiling) or review Query Store in SQL Server Management Studio (SSMS) to catch future instances of deprecated hint usage before they reach production.
  • Navigate to SSMS > Database > Reports > Standard Reports > Deprecated Features Usage to monitor ongoing occurrences.

Alternative or Verification Steps

  • After deploying the fix, re-execute the corrected INSERT statement in SSMS or Azure Data Studio and confirm that Error 8386 no longer appears in the Messages tab or the SQL Server Error Log.
  • As an alternative, if the hint is business-critical and cannot be removed immediately, suppress the warning temporarily by filtering Event ID 8386 in your monitoring tool (e.g., SCOM, SolarWinds) while scheduling a permanent code fix before the next major SQL Server upgrade.

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

Troubleshooting Guide: SQL Server Error 8384 — Deprecated Space-Separated Table Hints

Why This Error Happens

This error occurs because Microsoft SQL Server 2025 is enforcing stricter T-SQL syntax parsing rules, flagging legacy query syntax where multiple table hints are separated by spaces instead of commas. This is not a permissions or connectivity issue, but rather a code compatibility warning triggered by the query parser detecting outdated WITH (HINT1 HINT2) formatting. If left unaddressed, queries using this old syntax will fail entirely once the deprecated feature is fully removed in a future SQL Server update.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Queries

  • Check the SQL Server Error Log or Extended Events session for Error 8384 occurrences.
  • Run the following query against the system_health session to capture recent deprecation warnings:
  SELECT object_name, CAST(event_data AS XML) AS EventDetails
  FROM sys.fn_xe_file_target_read_file('system_health*.xel', NULL, NULL, NULL)
  WHERE object_name = 'deprecation_announcement';
  • Cross-reference the flagged object names (stored procedures, views, or ad-hoc scripts) with your codebase.

Step 2: Update Table Hint Syntax in T-SQL Code

  • Locate instances of space-separated hints, such as:
  SELECT * FROM Orders WITH (NOLOCK READPAST)
  • Replace the space with a comma to conform to the updated standard:
  SELECT * FROM Orders WITH (NOLOCK, READPAST)
  • Use a global search (Ctrl+Shift+F in SSMS or Azure Data Studio) across your .sql files for the pattern WITH ( to locate all affected scripts.

Step 3: Update Stored Procedures and Views

  • Script out all stored procedures and views using sp_helptext or SSMS “Generate Scripts” wizard.
  • Modify the WITH (...) clauses in each object definition to use commas.
  • Redeploy the updated objects using ALTER PROCEDURE or ALTER VIEW statements to ensure the corrected syntax is saved to the database.

Step 4: Enable Deprecation Tracking for Ongoing Monitoring

  • Configure a permanent Extended Events session to catch future deprecated syntax usage:
  CREATE EVENT SESSION TrackDeprecatedFeatures
  ON SERVER
  ADD EVENT sqlserver.deprecation_announcement
  ADD TARGET package0.event_file(SET filename=N'DeprecationTrace.xel');
  GO
  ALTER EVENT SESSION TrackDeprecatedFeatures ON SERVER STATE = START;
  • This ensures visibility into any legacy code that slips through code review.

Alternative or Verification Steps

  • Re-run the previously failing query or stored procedure in SQL Server Management Studio (SSMS) and confirm Error 8384 no longer appears in the Messages tab.
  • If the warning persists, verify you are not calling a linked server or synonym that references an outdated version of the object; refresh the synonym or update the linked server’s cached procedure definition.

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

Troubleshooting Guide: SQL Server Error 8385

Why This Error Happens

This error occurs because SQL Server, starting with 90 compatibility mode, enforces a strict requirement that any indexed view containing an aggregate function must also explicitly include COUNT_BIG(*) in its SELECT list. This requirement exists because SQL Server’s Query Optimizer relies on COUNT_BIG(*) to efficiently maintain and verify row counts within the clustered index of the view during incremental updates. Without this column, the engine cannot guarantee the integrity of aggregate calculations (like SUM, AVG, or COUNT) when underlying base table data changes, so it blocks the index creation entirely.

Step-by-Step Resolution Guide

Step 1: Identify the Offending View Definition

  • Open SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your SQL Server 2025 instance.
  • Locate the specific view script that failed during index creation by checking the error context in the Messages tab.
  • Run sp_helptext 'YourSchema.YourViewName' to pull the exact current definition of the view for editing.

Step 2: Modify the View to Include COUNT_BIG(*)

  • Alter the view definition to add COUNT_BIG(*) AS RecordCount (or similar alias) directly into the SELECT list alongside your existing aggregates.
  • Ensure this addition does not interfere with the GROUP BY clause, which must remain unchanged.
  • Example syntax to use in your ALTER VIEW statement:
  ALTER VIEW dbo.YourAggregateView
  WITH SCHEMABINDING
  AS
  SELECT 
      OrderID, 
      SUM(Quantity) AS TotalQty, 
      COUNT_BIG(*) AS RecordCount
  FROM dbo.OrderDetails
  GROUP BY OrderID;

Step 3: Recreate the Unique Clustered Index

  • Navigate to the Object Explorer in SSMS, expand the Views folder, and locate your specific view.
  • Re-run the CREATE UNIQUE CLUSTERED INDEX statement that previously failed, pointing it toward the newly altered view.
  • Verify the compatibility level of the database by running SELECT compatibility_level FROM sys.databases WHERE name = 'YourDBName'; to confirm it is still set to 90 or higher, ensuring the rule applies correctly to the new structure.

Alternative or Verification Steps

  • Verify the Fix: Query sys.indexes and sys.views to confirm the clustered index status is now “Enabled,” or simply attempt to re-run the original CREATE INDEX script to ensure it completes without throwing Error 8385.
  • Alternative Workaround: If modifying the view schema is not immediately possible due to downstream dependencies, consider using a standard non-clustered index on the underlying base tables instead of an indexed view, as this bypasses the strict COUNT_BIG(*) requirement entirely.

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

Troubleshooting Guide: SQL Server Error 8383 – Deprecated HOLDLOCK Table Hint Syntax

Why This Error Happens

This warning occurs because legacy Transact-SQL code specifies the HOLDLOCK table hint directly after a table name without enclosing it in parentheses (e.g., SELECT * FROM Table1 HOLDLOCK instead of SELECT * FROM Table1 WITH (HOLDLOCK)). SQL Server 2025 still supports this older syntax for backward compatibility, but it has been formally marked for removal in a future release. The error is raised by the SQL Server Database Engine’s deprecation tracking feature, not because of a permissions issue or corrupted file, but simply because the parser detects non-compliant syntax during query compilation.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Queries

  • Use SQL Server Profiler or Extended Events to capture the Deprecation Announcement event class, filtering specifically for the HOLDLOCK feature ID.
  • Alternatively, run a query against sys.dm_os_performance_counters filtering on the Deprecated Features object to confirm how often the legacy syntax is being used.
  • Search your codebase (stored procedures, views, functions) using sys.sql_modules with a LIKE '%HOLDLOCK%' filter to locate exact line numbers.

Step 2: Update the Table Hint Syntax

  • Modify every instance of the bare hint to use the compliant bracketed syntax: change FROM Orders HOLDLOCK to FROM Orders WITH (HOLDLOCK).
  • If multiple hints are chained, ensure they are comma-separated inside the single parentheses block, such as WITH (HOLDLOCK, ROWLOCK).
  • Save and redeploy the updated stored procedures or application code to your Windows Server 2025 instance.

Step 3: Clear the Procedure Cache and Recompile

  • Execute DBCC FREEPROCCACHE to remove the old execution plans associated with the deprecated syntax (run this during a maintenance window to avoid performance dips from plan recompilation).
  • Alternatively, use sp_recompile 'YourStoredProcedureName' to force a recompile of a specific object.
  • Restart the SQL Server (MSSQLSERVER) service via the Services console (services.msc) on Windows Server 2025 if cached plans persist in triggering the warning.

Step 4: Enable Trace Flag for Validation (Optional)

  • Temporarily enable Trace Flag 3609 or query the sys.dm_os_sys_info DMV to validate engine behavior remains unaffected after syntax changes.
  • Remove the trace flag once validation is complete to avoid unnecessary logging overhead in production.

Alternative or Verification Steps

  • Re-run the previously identified queries and confirm Error 8383 no longer appears in the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • As a quick alternative, if codebase changes cannot be immediately deployed, suppress the specific warning in client applications using SET DEPRECATION_WARNINGS OFF (test-environment only), but prioritize a full syntax fix before the next major SQL Server upgrade.

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

Troubleshooting Guide: Error 8381 – SQLOLEDB Provider No Longer Supported

Why This Error Happens

This error occurs because SQLOLEDB has been deprecated and removed as a supported ad hoc remote provider in SQL Server 2025, which enforces stricter OLE DB provider validation during linked server or distributed query operations. Legacy applications, scripts, or connection strings that explicitly call SQLOLEDB (instead of MSOLEDBSQL or SQLNCLI) will trigger this block since Microsoft no longer ships or registers that provider by default. Additionally, the DisallowAdhocAccess and AdHocDistributedQueriesEnabled settings may compound the issue if the replacement provider isn’t properly registered or configured on the host OS.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the SQLOLEDB Reference

  • Check connection strings in application config files (web.config, app.config, ODBC DSNs).
  • Search SSIS packages, linked server definitions, and legacy VBScript/ASP code for Provider=SQLOLEDB.
  • Run the following query to locate linked servers using the deprecated provider:
  SELECT name, product, provider, data_source 
  FROM sys.servers 
  WHERE provider = 'SQLOLEDB';

Step 2: Install and Register the Microsoft OLE DB Driver (MSOLEDBSQL)

  • Download the latest MSOLEDBSQL driver (or SQLNCLI if mandated by legacy compliance) from the Microsoft Download Center for Windows Server 2025/Windows 11.
  • Run the installer with elevated privileges:
  msiexec /i msoledbsql.msi IACCEPTMSOLEDBSQLLICENSETERMS=YES /quiet
  • Verify registration in the Windows Registry under:
    HKEY_CLASSES_ROOT\CLSID\{Provider_GUID}

Step 3: Update Linked Server and Connection String References

  • Modify existing linked servers via SQL Server Management Studio (SSMS) or T-SQL:
  EXEC sp_dropserver 'LegacyLinkedServer', 'droplogins';
  EXEC sp_addlinkedserver 
      @server='NewLinkedServer', 
      @provider='MSOLEDBSQL', 
      @datasrc='ServerName\InstanceName';
  • Update application connection strings from Provider=SQLOLEDB; to Provider=MSOLEDBSQL;.

Step 4: Configure Provider Options on the Server

  • In SSMS, navigate to Server Objects > Linked Servers > Providers > MSOLEDBSQL.
  • Right-click and select Properties, then enable:
  • Dynamic Parameters
  • Allow InProcess (only if required for performance; evaluate security implications first).

Alternative or Verification Steps

  • Run a test query via the updated linked server (SELECT * FROM OPENQUERY(NewLinkedServer, 'SELECT 1')) to confirm connectivity without Error 8381.
  • If MSOLEDBSQL is unavailable for your environment, use the ODBC Driver 18 for SQL Server with a DSN-based connection as a stable alternative to the deprecated OLE DB stack.

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

Troubleshooting Guide: SQL Server Error 8382 – Deprecated Table Hint Syntax

Why This Error Happens

This error occurs because SQL Server 2025 is flagging legacy T-SQL syntax where table hints (such as NOLOCK, INDEX, or ROWLOCK) are specified directly after a table name without being enclosed in the WITH (...) clause. This old-style syntax has been deprecated for several releases and is now actively surfaced as Error 8382 in preparation for complete removal in a future SQL Server version. The root cause is purely syntactical technical debt in stored procedures, views, or ad-hoc queries rather than a permissions or configuration issue.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Object

  • Check the SQL Server Error Log or Extended Events session for Error 8382 to capture the exact query text or object name triggering the warning.
  • Run the following query to search system objects for legacy hint usage:
  SELECT OBJECT_NAME(object_id), definition 
  FROM sys.sql_modules 
  WHERE definition LIKE '%(NOLOCK)%' 
     OR definition LIKE '%(ROWLOCK)%' 
     OR definition LIKE '%(INDEX%'
  • Cross-reference results with application connection logs to pinpoint ad-hoc queries sent from client applications.

Step 2: Rewrite Queries Using the WITH Keyword

  • Locate instances of the old syntax, for example: SELECT * FROM Orders (NOLOCK).
  • Rewrite them using the correct modern syntax: SELECT * FROM Orders WITH (NOLOCK).
  • If multiple hints are used, ensure they are comma-separated inside the parentheses, e.g., WITH (NOLOCK, INDEX(IX_Orders_Date)).
  • Update all affected stored procedures, functions, and views using SQL Server Management Studio (SSMS) 21 or Azure Data Studio.

Step 3: Deploy and Refresh Execution Plans

  • Script out the corrected object definitions using CREATE OR ALTER PROCEDURE to push updates without dropping permissions.
  • Clear the stale execution plan from the cache to force recompilation using: DBCC FREEPROCCACHE (<plan_handle>).
  • If using an ORM (e.g., Entity Framework or Dapper), update the raw SQL strings in the application source code and redeploy the application binaries to the Windows Server 2025 host.

Step 4: Enable Deprecation Monitoring (Optional)

  • Set up a persistent Extended Events session to catch future occurrences before they hit production:
  CREATE EVENT SESSION DeprecationMonitor ON SERVER 
  ADD EVENT sqlserver.deprecation_announcement
  ADD TARGET package0.event_file(SET filename=N'Deprecation.xel');
  ALTER EVENT SESSION DeprecationMonitor ON SERVER STATE = START;
  • Configure this session to write logs to a local path such as C:\SQLLogs\Deprecation\.

Alternative or Verification Steps

  • To verify the fix, re-run the query or execute the stored procedure in SSMS; the Messages tab should no longer display Error 8382, and the Extended Events session should show zero new events over a 24-hour monitoring window.
  • As an alternative if source code access is restricted, use the SQL Server Database Engine Tuning Advisor to analyze the workload and generate a corrected script of objects requiring the WITH syntax update.

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

Troubleshooting Guide: Error 8380 – SQLOLEDB Provider Not Supported

Why This Error Happens

This error occurs because SQLOLEDB has been deprecated and removed as a supported OLE DB provider in SQL Server 2025, as Microsoft has fully transitioned to the Microsoft OLE DB Driver (MSOLEDBSQL) and ODBC-based connectivity. Any linked server definition, connection string, or legacy application that explicitly references the SQLOLEDB or SQLNCLI provider string will fail because the underlying provider DLL is no longer registered on the system. This is common after migrating databases or restoring linked server configurations from older SQL Server instances (2016 and earlier) that still relied on these legacy providers.

Step-by-Step Resolution Guide

Step 1: Identify the Affected Linked Server

  • Open SQL Server Management Studio (SSMS) and expand Server Objects > Linked Servers.
  • Right-click the linked server named in the error message and select Properties to view the current provider.
  • Alternatively, run the following query to list all linked servers and their providers:
  SELECT name, provider, data_source FROM sys.servers WHERE is_linked = 1;

Step 2: Install the Microsoft OLE DB Driver (MSOLEDBSQL)

  • Download and install the latest Microsoft OLE DB Driver 19 (or newer) for SQL Server from the official Microsoft Download Center.
  • Run the installer as Administrator on the Windows Server 2025 / Windows 11 machine hosting the SQL Server instance.
  • Verify installation by checking the registry path: HKEY_CLASSES_ROOT\MSOLEDBSQL.1.

Step 3: Recreate the Linked Server with the Updated Provider

  • Drop the existing broken linked server:
  EXEC sp_dropserver 'YourLinkedServerName', 'droplogins';
  • Recreate it using MSOLEDBSQL instead of SQLOLEDB or SQLNCLI:
  EXEC sp_addlinkedserver 
      @server = 'YourLinkedServerName', 
      @provider = 'MSOLEDBSQL', 
      @datasrc = 'YourTargetServer';
  • Re-map the login credentials using sp_addlinkedsrvlogin as required.

Step 4: Update Application Connection Strings

  • Search any legacy applications, SSIS packages, or scripts for Provider=SQLOLEDB or Provider=SQLNCLI.
  • Replace these strings with Provider=MSOLEDBSQL in connection configuration files (e.g., .config, .dtsx, or .udl files).
  • Restart the application pool or service to apply the updated connection string.

Alternative or Verification Steps

  • Verify the Fix: Run a test query through the linked server (e.g., SELECT * FROM [YourLinkedServerName]...[TableName]) to confirm connectivity without triggering Error 8380.
  • Alternative Path: If MSOLEDBSQL is unavailable due to compliance restrictions, configure connectivity using the ODBC Driver 18 for SQL Server via a DSN-based linked server setup as a fallback.

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

Troubleshooting Guide: Error 8379 – Deprecated Old-Style RAISERROR Syntax in SQL Server 2025

Why This Error Happens

This error occurs because legacy Transact-SQL code is using the old-style RAISERROR syntax in the format RAISERROR integer string, which bypasses the standard parenthesized function call format introduced in later SQL Server versions. Microsoft has flagged this syntax as deprecated since it does not support the full feature set of formatted error messages (such as severity levels, states, and substitution parameters). SQL Server 2025 now surfaces this as a hard warning (Error 8379) to prepare developers for its eventual removal in a future release.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Code

  • Search all stored procedures, triggers, and scripts for instances of RAISERROR not using parentheses.
  • Run the following query against your database to locate affected objects:
  SELECT OBJECT_NAME(object_id), definition 
  FROM sys.sql_modules 
  WHERE definition LIKE '%RAISERROR%' AND definition NOT LIKE '%RAISERROR(%'
  • Check SQL Server Error Logs or Extended Events session output for Error 8379 to pinpoint exact session/query IDs triggering the warning.

Step 2: Convert to Modern RAISERROR Syntax

  • Replace the old format: RAISERROR 50001 'Custom error message'
  • With the standard parenthesized format: RAISERROR (50001, 16, 1, 'Custom error message')
  • Ensure you specify severity (e.g., 16) and state (e.g., 1) explicitly, as these are mandatory in the new syntax.
  • For simple messages, consider migrating fully to the newer THROW statement instead: THROW 50001, 'Custom error message', 1;

Step 3: Update Compatibility Level and Test Scripts

  • Navigate to SQL Server Management Studio (SSMS) and right-click the Database > Properties > Options.
  • Verify the Compatibility Level is set to SQL Server 2025 (160) to ensure the engine is validating against the latest deprecation rules.
  • Execute the modified stored procedures in a Staging/Dev environment to confirm the error 8379 no longer appears in the Messages tab.

Step 4: Audit Dependencies and Deploy

  • Use SQL Server Data Tools (SSDT) or a schema compare tool to check if any application-side C#/Java code expects the old error string format.
  • Deploy the updated scripts to Production using a standard change-management window via SQLCMD or Azure Data Studio.

Alternative or Verification Steps

  • Verification: Re-run the object creation scripts (CREATE OR ALTER PROCEDURE) and check the Output/Messages pane in SSMS; the deprecation warning (8379) should be absent, and the error should trigger correctly with the specified severity level.
  • Alternative: If refactoring the entire codebase is not immediately feasible, suppress the warning logging by filtering Event ID 8379 in the SQL Server Error Log viewer, but note this is a temporary workaround, not a fix, as the syntax will eventually cause a hard failure in a future upgrade.

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

Troubleshooting Guide: SQL Server Error 8359 – SQL Trace Event Notification Memory Failure

Why This Error Happens

Error 8359 occurs when SQL Server’s internal memory broker cannot allocate sufficient memory to queue or dispatch an Event Notification through Service Broker, typically because the SQL Trace subsystem is competing with other memory consumers under pressure from a constrained memory grant. This is often triggered by an undersized “max server memory” configuration relative to workload, a backlog of unconsumed messages in the target Service Broker queue, or memory fragmentation caused by excessive ad-hoc query plans. In some cases, the error is transient and self-resolves once memory pressure subsides, but recurring instances point to a systemic resource bottleneck.

Step-by-Step Resolution Guide

Step 1: Verify Current Memory Configuration and Pressure

  • Open SQL Server Management Studio (SSMS) and run EXEC sp_configure 'max server memory' to check the current ceiling.
  • Query sys.dm_os_memory_clerks ordered by pages_kb DESC to identify which component (e.g., MEMORYCLERK_SQLSERVICEBROKER) is consuming the most memory.
  • Check Windows Performance Monitor (perfmon) for the counter SQLServer:Memory Manager > Total Server Memory (KB) vs. Target Server Memory (KB) to confirm the instance is memory-starved.

Step 2: Clear the Service Broker Queue Backlog

  • Run the following to identify unprocessed messages in the event notification target queue:
SELECT * FROM sys.transmission_queue;
SELECT name, is_receive_enabled FROM sys.service_queues;
  • If a queue has excessive unprocessed messages, temporarily disable and re-enable it to force a flush:
ALTER QUEUE [YourQueueName] WITH STATUS = OFF;
ALTER QUEUE [YourQueueName] WITH STATUS = ON;
  • Restart the SQL Trace session using sp_trace_setstatus if a custom trace (not Extended Events) is active.

Step 3: Adjust Max Server Memory and Reserve Headroom for the OS

  • In SSMS, go to Server Properties > Memory, or run:
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'max server memory', 16384; -- adjust value in MB based on total RAM
RECONFIGURE;
  • On Windows Server 2025 / Windows 11, ensure at least 2–4 GB (or 10-15% of total RAM) is reserved for the OS and non-SQL processes to prevent paging-driven memory errors.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER for the setting to fully apply.

Step 4: Migrate from SQL Trace to Extended Events

  • Since SQL Trace is deprecated in SQL Server 2025, recreate your trace definitions as an Extended Events session, which uses a more memory-efficient buffering model.
  • Use the built-in “Convert Trace File to Extended Events Session” wizard in SSMS under Management > Extended Events.
  • This eliminates legacy event notification memory brokers that are the primary source of Error 8359.

Alternative or Verification Steps

  • After applying changes, run SELECT * FROM sys.messages WHERE message_id = 8359; alongside checking the SQL Server Error Log (EXEC xp_readerrorlog) to confirm the event no longer recurs during peak load.
  • If the error persists despite available memory, check for a corrupted Service Broker route or certificate (SELECT * FROM sys.routes;) and re-run ALTER DATABASE [YourDB] SET ENABLE_BROKER; to reset the broker state as a last-resort fix.

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

Troubleshooting Guide: SQL Server Error 8360 – SQL Trace Event Notification Failure

Why This Error Happens

Error 8360 occurs when SQL Server’s Service Broker, which handles event notification delivery for SQL Trace, is unable to queue or send a message due to insufficient memory, worker thread exhaustion, or a full transmission queue. This is typically a symptom of underlying resource pressure on the server, such as high memory consumption by other processes or an undersized max server memory configuration. In some cases, this can also occur if the msdb database or the Service Broker queues associated with event notifications have become corrupted or disabled.

Step-by-Step Resolution Guide

Step 1: Verify Server Resource Availability

  • Open Task Manager or Performance Monitor (PerfMon) on Windows Server 2025 to check current memory and CPU utilization.
  • Check the SQLServer:Memory Manager counter for “Memory Grants Pending,” as a high value indicates active memory starvation.
  • Review the SQL Server Error Log (via SSMS > Management > SQL Server Logs) for concurrent Out of Memory (OOM) warnings that often accompany Error 8360.

Step 2: Adjust SQL Server Memory Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the instance via the Query Editor.
  • Run sp_configure 'max server memory (MB)' to check the current limit.
  • Ensure the value leaves at least 4GB to 10% of total RAM (whichever is greater) available for the Windows Server 2025 OS to prevent paging.
  • Execute: EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'max server memory', 16384; RECONFIGURE; (Adjust the MB value based on your total system RAM).

Step 3: Check and Repair Service Broker Status

  • Verify that Service Broker is enabled for the msdb database, as it is required for internal trace event notifications.
  • Run the following query to check the status: SELECT name, is_broker_enabled FROM sys.databases WHERE name = 'msdb';
  • If the result returns 0, enable it by running: ALTER DATABASE msdb SET ENABLE_BROKER;
  • Restart the SQL Server (MSSQLSERVER) service via the Services console (services.msc) to clear any hung Broker queues.

Step 4: Switch to File-Based Tracing (If using SQL Trace specifically)

  • Since SQL Trace relies on Service Broker for notifications, consider migrating critical traces to Extended Events, which is natively more resource-efficient in SQL Server 2025.
  • If you must continue using the legacy Trace, redirect the output to a local file system path (e.g., D:\SQLTraces\) rather than relying on event notifications to reduce overhead.

Alternative or Verification Steps

  • Verification: After implementing the memory fix, monitor the SQL Server Error Log for 24–48 hours to confirm Error 8360 does not recur during peak load times.
  • Alternative: If the error persists despite available resources, run DBCC CHECKDB('msdb') to rule out corruption in the system database hosting the Service Broker objects.

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

Troubleshooting Guide: SQL Server Error 8358 – ETW Event Message Size Exceeds Limit

Why This Error Happens

This error occurs when SQL Server 2025 attempts to write a diagnostic or trace event through Event Tracing for Windows (ETW) that exceeds the maximum buffer size allowed per event (typically 64KB per ETW session buffer). This is often triggered by overly verbose extended events sessions, large query plans, or oversized Always On Availability Group diagnostic payloads being captured in a single ETW event. It can also occur if the ETW session buffer configuration is undersized relative to the volume of telemetry SQL Server is attempting to emit, or if a system component is generating malformed/oversized trace payloads due to a corrupted provider manifest.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the Oversized Event

  • Open Event Viewer and navigate to Applications and Services Logs > Microsoft > Windows > Diagnostics-Networking or the SQL Server-specific ETW provider logs.
  • Cross-reference the timestamp of Error 8358 with SQL Server’s ERRORLOG (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) to identify which subsystem (Extended Events, Query Store, or AG Health Monitor) triggered the event.
  • Run the following query to check active XEvent sessions that may be generating large payloads:
  SELECT * FROM sys.dm_xe_sessions WHERE name NOT LIKE 'system_health%';

Step 2: Increase or Adjust the ETW Session Buffer Size

  • Open an elevated PowerShell prompt and check the current logman configuration for the SQL Server trace session:
  logman query "SQLServerTrace" -ets
  • Increase the buffer size allocation (in KB) to accommodate larger payloads:
  logman update trace "SQLServerTrace" -bs 128 -nb 32 64 -ets
  • If using Extended Events, reduce the MAX_MEMORY target size or switch the target from ring_buffer to event_file to avoid in-memory size constraints:
  ALTER EVENT SESSION [YourSessionName] ON SERVER
  DROP TARGET package0.ring_buffer;

Step 3: Disable or Scope Down Verbose Extended Events Sessions

  • Identify and disable any custom Extended Events sessions capturing full sql_text or query_plan actions, as these are common culprits for oversized events:
  ALTER EVENT SESSION [YourSessionName] ON SERVER STATE = STOP;
  • Avoid using the query_post_execution_showplan action on high-volume workloads, as execution plans for complex queries frequently exceed the 64KB ETW payload limit.

Step 4: Repair or Re-register the ETW Provider Manifest

  • If the issue persists even with low-volume sessions, the SQL Server ETW manifest (sqlos.man) may be corrupted. Re-register it using:
  wevtutil um "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\sqlos.man"
  wevtutil im "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\sqlos.man"
  • Restart the SQL Server service (MSSQLSERVER) after re-registration to apply the refreshed manifest.

Alternative or Verification Steps

  • After applying changes, monitor the SQL ERRORLOG and Windows Application Event Log for 24–48 hours to confirm Error 8358 no longer appears during peak workload periods.
  • As an alternative, if the error originates from a non-critical monitoring session, you can safely suppress it by setting trace flag -T8358 at startup (via SQL Server Configuration Manager startup parameters) to prevent the warning from being logged, provided the underlying telemetry loss is acceptable for your monitoring requirements.

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

Troubleshooting Guide: SQL Server Error 8356 (ETW Event Send Failure)

Why This Error Happens

Error 8356 occurs when SQL Server’s Event Tracing for Windows (ETW) provider cannot allocate sufficient memory from the non-paged or session pool to buffer and send diagnostic events to the tracing session. This is typically caused by memory pressure on the host system, an overly large number of concurrent ETW consumers/sessions competing for buffer space, or a misconfigured trace session buffer size that cannot accommodate the current event volume. In some cases, this is also triggered by fragmented kernel memory on Windows Server 2025 when multiple diagnostic tools (XEvents, Perfmon, third-party APM agents) attach to the same provider simultaneously.

Step-by-Step Resolution Guide

Step 1: Verify System-Wide Memory Pressure

  • Open Performance Monitor (perfmon.exe) and check the Memory > Available MBytes and Memory > Pool Nonpaged Bytes counters.
  • If Available MBytes is critically low (under 10% of total RAM), close unnecessary services or increase the VM/physical RAM allocation.
  • Run Get-Counter '\Memory\Pool Nonpaged Bytes' in PowerShell to confirm kernel pool exhaustion.

Step 2: Audit and Reduce Active ETW Trace Sessions

  • Run logman query -ets in an elevated Command Prompt to list all active trace sessions.
  • Identify redundant or orphaned sessions (common culprits: leftover SQLTrace, NT Kernel Logger, or third-party monitoring agent sessions).
  • Stop unnecessary sessions using logman stop <SessionName> -ets.
  • If SQL Server Extended Events (XEvents) sessions are misconfigured, review them via SSMS under Management > Extended Events > Sessions and disable any with excessive event firing rates.

Step 3: Adjust ETW Buffer Size and Count Settings

  • Navigate to the SQL Server Extended Events session properties in SSMS.
  • Under Advanced, increase the Max Dispatch Latency and Event Retention Mode settings (set retention to ALLOW_SINGLE_EVENT_LOSS to prevent blocking under memory pressure).
  • Alternatively, modify buffer size via T-SQL:
ALTER EVENT SESSION [YourSessionName] ON SERVER
WITH (MAX_MEMORY = 8192 KB, MEMORY_PARTITION_MODE = PER_NODE);
  • Restart the SQL Server service (net stop MSSQLSERVER && net start MSSQLSERVER) to apply changes cleanly.

Step 4: Apply Latest Cumulative Update and OS Patches

  • Confirm SQL Server 2025 is on the latest Cumulative Update (CU) via SELECT @@VERSION;.
  • Check Windows Server 2025 / Windows 11 for pending updates under Settings > Windows Update, as known ETW kernel pool leaks have been addressed in recent patches.
  • Reboot the server after patching to clear any residual kernel memory fragmentation.

Alternative or Verification Steps

  • After applying fixes, monitor the SQL Server Error Log and Windows Event Viewer (Application log) for 24–48 hours to confirm Error 8356 no longer recurs.
  • If the issue persists, use logman query providers | findstr SQL to confirm no duplicate SQL ETW providers are registered, and consider isolating diagnostic tools (e.g., disable third-party APM tracing temporarily) to identify the specific session causing memory contention.

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

Troubleshooting Guide: SQL Server Error 8357 – ETW Event Send Failure

Why This Error Happens

Error 8357 occurs when SQL Server’s internal Extended Events engine attempts to publish diagnostic data to the Event Tracing for Windows (ETW) subsystem, but the operating system cannot allocate a buffer for the event due to constrained system resources. This is typically triggered by exhausted non-paged pool memory, an overloaded ETW session buffer configuration, or too many simultaneous Extended Events sessions writing to the same trace target. In most cases, this is a transient warning rather than a critical failure, but persistent occurrences indicate a deeper resource bottleneck on the host.

Step-by-Step Resolution Guide

Step 1: Check System Resource Utilization

  • Open Performance Monitor (perfmon.exe) and review the Memory > Pool Nonpaged Bytes counter for abnormal growth.
  • Check Task Manager or Get-Counter "\Memory\Available MBytes" in PowerShell to confirm free memory isn’t critically low.
  • Review Windows Event Viewer under Applications and Services Logs > Microsoft > Windows > Kernel-EventTracing for related warnings.

Step 2: Reduce Active Extended Events Sessions

  • Run the following query to identify active sessions consuming ETW resources:
  SELECT name, event_session_id FROM sys.dm_xe_sessions;
  • Stop any non-essential or redundant sessions using:
  ALTER EVENT SESSION [SessionName] ON SERVER STATE = STOP;
  • Avoid running multiple custom Extended Events sessions with overlapping targets simultaneously.

Step 3: Increase ETW Buffer Size and Count

  • Navigate to the Extended Events session properties in SQL Server Management Studio (SSMS) under Management > Extended Events > Sessions.
  • Right-click the relevant session, select Properties > Advanced, and increase Max Dispatch Latency and Event Retention Mode settings to reduce buffer pressure.
  • Alternatively, modify the session via T-SQL:
  ALTER EVENT SESSION [SessionName] ON SERVER
  WITH (MAX_DISPATCH_LATENCY = 30 SECONDS, MAX_MEMORY = 8192 KB);

Step 4: Adjust System-Wide ETW Logging Limits

  • Open an elevated Command Prompt and check current logman sessions:
  logman query -ets
  • Increase the global ETW buffer allocation via the registry path:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\Autologger
  • Adjust the BufferSize and MaximumBuffers DWORD values upward (e.g., from default 64 KB to 128 KB) and restart the Windows Event Log service.

Step 5: Apply Latest SQL Server 2025 Cumulative Update

  • Verify your current build version using:
  SELECT @@VERSION;
  • Download and install the latest Cumulative Update (CU) from the Microsoft Update Catalog, as known ETW buffer-handling fixes are frequently included in servicing releases.
  • Restart the SQL Server service after patching to apply changes.

Alternative or Verification Steps

  • After applying fixes, monitor the SQL Server Error Log and Windows Application Event Log for 24–48 hours to confirm Error 8357 no longer appears.
  • If the error persists despite buffer increases, disable non-critical Extended Events sessions entirely (especially the system_health session temporarily) to isolate whether a specific trace target is causing the resource strain.

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

Troubleshooting Guide: Error 8355 — Server-Level Event Notifications Cannot Be Delivered

Why This Error Happens

This error occurs because Service Broker, the underlying messaging technology that SQL Server uses to deliver event notifications, is disabled on the msdb system database. Service Broker can be turned off due to a database restore operation (which disables it by default for security reasons), manual misconfiguration, or a mismatch in the Service Broker GUID after a database copy. Without an active Service Broker, SQL Server has no transport mechanism to route the notification messages to their target queue, causing them to silently fail with Error 8355.

Step-by-Step Resolution Guide

Step 1: Verify Current Service Broker Status

  • Open SQL Server Management Studio (SSMS) and connect to your SQL Server 2025 instance.
  • Run the following query to check the status:
SELECT name, is_broker_enabled, service_broker_guid 
FROM sys.databases 
WHERE name = 'msdb';
  • If is_broker_enabled returns 0, this confirms Service Broker is disabled and is the root cause.

Step 2: Enable Service Broker on msdb

  • Ensure no active connections are using msdb before proceeding, as this operation requires exclusive access.
  • Open a new query window in SSMS running under an account with sysadmin privileges.
  • Execute the following command to enable it:
ALTER DATABASE msdb SET ENABLE_BROKER;
  • If the command hangs, it likely means there are open transactions on msdb; in that case, use the WITH ROLLBACK IMMEDIATE option instead:
ALTER DATABASE msdb SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;

Step 3: Restart the SQL Server Service

  • Open the Services console on Windows Server 2025 (services.msc).
  • Locate SQL Server (MSSQLSERVER) or your named instance.
  • Right-click and select Restart to ensure the Service Broker task list is reinitialized correctly in memory.

Step 4: Check for Service Broker GUID Mismatches

  • If Step 2 did not resolve the issue, the service_broker_guid in msdb may not match the value expected by the instance (common after a server migration).
  • Run the following query to regenerate a new GUID and resync the broker identity:
ALTER DATABASE msdb SET NEW_BROKER;
  • Note: Use this only if you do not need existing conversation groups preserved, as this command clears the message queues.

Alternative or Verification Steps

  • To verify the fix, run SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb'; again; a return value of 1 confirms the resolution was successful.
  • If notifications are still not received, check the Windows Firewall settings on Windows Server 2025 to ensure TCP port 4022 (the default Service Broker endpoint port) is not being blocked by inbound rules.

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

Troubleshooting Guide: SQL Server Error 8353 – Event Tracing for Windows Failed to Start

Why This Error Happens

Error 8353 occurs when SQL Server 2025 attempts to initialize its Event Tracing for Windows (ETW) provider during startup but cannot register with the Windows ETW subsystem. This is typically caused by insufficient permissions on the SQL Server service account (lacking the “Generate security audits” or ETW logon rights), a corrupted or missing ETW session configuration, or a conflict with another process holding an exclusive ETW session handle. In some cases, this also results from a damaged Windows ETW manifest registration tied to the sqlservr.exe binary, which can happen after an incomplete patch or in-place upgrade on Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify SQL Server Service Account Permissions

  • Open Local Security Policy (secpol.msc) and navigate to Local Policies > User Rights Assignment.
  • Confirm the SQL Server service account is listed under “Log on as a service” and has no explicit deny rules.
  • Add the account to the Performance Log Users group via lusrmgr.msc (or Active Directory Users and Computers for domain accounts), since this group grants ETW session control rights.

Step 2: Re-register the ETW Provider Manifest

  • Open an elevated Command Prompt and navigate to the SQL Server binaries directory:
    cd "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn"
  • Unregister and re-register the ETW manifest using:
    wevtutil um sqlos.man
    wevtutil im sqlos.man
  • Restart the SQL Server (MSSQLSERVER) service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.

Step 3: Check for Conflicting ETW Sessions

  • Run logman query -ets in an elevated PowerShell window to list active trace sessions.
  • Look for orphaned sessions named MSSQL_SQLTRACE or similar and stop them manually:
    logman stop "MSSQL_SQLTRACE" -ets
  • Reboot Windows Server 2025 if sessions cannot be stopped cleanly, as this clears any stuck kernel-mode ETW handles.

Step 4: Repair SQL Server Installation

  • Launch SQL Server Installation Center from the Start Menu.
  • Select Maintenance > Repair, choose the affected instance, and allow the repair wizard to restore corrupted ETW-related binaries and registry keys.
  • Reboot the server after the repair completes to finalize driver and provider registration.

Alternative or Verification Steps

  • After applying the fix, check the Windows Event Viewer under Applications and Services Logs > Microsoft > SQL Server to confirm Error 8353 no longer appears on service restart.
  • As an alternative, run tracelog -stop MSSQL_ETW followed by a full server reboot to force Windows to release any locked ETW resources before retrying the SQL Server service start.

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

Troubleshooting Guide: SQL Server Error 8354 – ETW Event Send Failure

Why This Error Happens

Error 8354 occurs when SQL Server’s internal Event Tracing for Windows (ETW) provider is unable to transmit diagnostic events to the Windows tracing subsystem. This is typically caused by a corrupted or unregistered ETW manifest for the SQL Server binary, insufficient permissions on the EventLog or ETW session registry keys, or an ETW session buffer that has become exhausted or locked by another tracing application (such as Perfmon or a third-party APM tool). In some cases, this is also triggered by a mismatch between the SQL Server binary version and its registered trace manifest after an in-place upgrade or cumulative update.

Step-by-Step Resolution Guide

Step 1: Verify and Re-register the ETW Manifest

  • Open an elevated Command Prompt on the Windows Server 2025 / Windows 11 host.
  • Navigate to the SQL Server binary directory, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\.
  • Run wevtutil um sqlos.man to unregister the existing manifest, followed by wevtutil im sqlos.man to re-register it cleanly.
  • Restart the SQL Server (MSSQLSERVER) service to force the engine to re-bind to the ETW provider.

Step 2: Check and Reset ETW Session Permissions

  • Open Registry Editor (regedit) and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\Security.
  • Locate the GUID associated with the SQL Server trace provider (commonly {A94B6E48-471A-485C-A1C8-80C0092C2DAD} for SQL Server diagnostics).
  • Ensure the NT SERVICE\MSSQLSERVER account has Full Control on this key; if missing, add it via the Security tab.
  • Confirm the Performance Logs & Alerts local security policy includes the SQL Server service account.

Step 3: Clear Stale or Conflicting ETW Sessions

  • Run logman query -ets in an elevated PowerShell window to list all active trace sessions.
  • Identify any stuck or duplicate sessions referencing MSSQL_TRACE or SQLTraceSession.
  • Stop the conflicting session using logman stop "<SessionName>" -ets and delete it with logman delete "<SessionName>" -ets.
  • Restart the SQL Server service to allow it to create a fresh, unobstructed ETW session.

Step 4: Apply the Latest Cumulative Update

  • Check the installed build number via SELECT @@VERSION; in SQL Server Management Studio (SSMS).
  • Compare it against the latest Cumulative Update (CU) for SQL Server 2025 on the Microsoft Update Catalog.
  • Download and install the latest CU, as this error is frequently patched due to manifest versioning bugs between RTM and early CUs.
  • Reboot the server after installation to ensure the ETW provider binaries are fully reloaded.

Alternative or Verification Steps

  • After applying the fix, monitor the SQL Server Error Log and Windows Application Event Log for 24–48 hours to confirm Error 8354 no longer appears.
  • If the issue persists, run tracelog -stop for any legacy trace sessions, then use Process Monitor (ProcMon) filtered to sqlservr.exe to check for ACCESS DENIED results on registry or ETW-related system calls, which can pinpoint a deeper permissions issue.

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

Troubleshooting Guide: SQL Server Error 8352 — “Cannot Find the Requested Trace Template”

Why This Error Happens

This error typically occurs when SQL Server’s XEvent or SQL Trace subsystem cannot locate the internal trace template definition referenced by its GUID or name (id = %ls), usually because the metadata catalog views (such as sys.traces or the Extended Events metadata) have become desynchronized from the underlying binary template files. This can happen after an in-place upgrade from a previous SQL Server version, a corrupted or missing .xel/template registration in the Resource Database, or when a third-party monitoring tool (APM/DBA tooling) references a trace template ID that was removed or never properly registered during installation. In rarer cases, this is triggered by permission restrictions on the mssqlsystemresource database preventing SQL Server from reading the template definitions at runtime.

Step-by-Step Resolution Guide

Step 1: Verify the Resource Database Integrity

  • Open SQL Server Configuration Manager and confirm the SQL Server service account has read access to the mssqlsystemresource.mdf and .ldf files, typically located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\.
  • Run DBCC CHECKDB ('mssqlsystemresource') WITH NO_INFOMSGS, ALL_ERRORMSGS; in SSMS to confirm there is no corruption.
  • If corruption is found, restore the Resource Database files from the original SQL Server 2025 installation media or a known-good backup.

Step 2: Rebuild or Refresh Trace Metadata Cache

  • Stop any active Extended Events sessions tied to custom trace templates using ALTER EVENT SESSION [SessionName] ON SERVER STATE = STOP;
  • Clear the plan and metadata cache with DBCC FREESYSTEMCACHE ('ALL'); to force SQL Server to reload trace template references.
  • Restart the SQL Server service (services.msc → SQL Server (MSSQLSERVER) → Restart) to re-initialize the trace subsystem cleanly.

Step 3: Repair or Reinstall Shared Trace Components

  • Launch the SQL Server 2025 Installation Center, select Maintenance > Repair, and choose the affected instance to restore missing trace template DLLs and resource files.
  • Confirm that Microsoft.SqlServer.XEvent.Trace.dll and related files in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\ are present and not flagged by antivirus/Windows Defender as quarantined.
  • If using Windows Server 2025 Hardened Policies, check Windows Defender Application Control (WDAC) logs to ensure the trace DLLs are not being blocked from loading.

Step 4: Validate Third-Party Monitoring Tool Configuration

  • If the error originates from an APM or monitoring agent (e.g., SolarWinds, Redgate, SQL Sentry), confirm the tool is updated to a version certified for SQL Server 2025.
  • Remove and recreate any custom trace or Extended Events session definitions configured by the tool to regenerate valid template IDs.

Alternative or Verification Steps

  • After applying fixes, run SELECT * FROM sys.fn_trace_getinfo(NULL); and SELECT * FROM sys.dm_xe_sessions; to confirm templates load without error.
  • If Error 8352 persists, as a fallback, disable legacy SQL Trace entirely (deprecated in SQL Server 2025) and migrate all monitoring exclusively to Extended Events sessions using the built-in “Standard” or “Profiler Standard” templates in SSMS.

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

Troubleshooting Guide: SQL Server Error 8350 – Deprecated NOLOCK/READUNCOMMITTED Hints on UPDATE/DELETE Target Tables

Why This Error Happens

This error occurs because SQL Server 2025 has deprecated the use of NOLOCK or READUNCOMMITTED table hints when applied directly to the target table of an UPDATE or DELETE statement’s FROM clause. These hints were historically ignored by the query optimizer in this context since you cannot read uncommitted data on a row you are actively modifying, making their presence functionally meaningless. SQL Server 2025 now actively flags this syntax to encourage cleanup of legacy T-SQL code before the behavior potentially becomes a hard error in a future compatibility level.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Capture the exact statement text from the error message (the %.*ls placeholder will show the specific table name in your actual error log).
  • Use Extended Events or the SQL Server Error Log in Windows Server 2025 to trace which stored procedures or ad-hoc scripts are triggering Event ID 8350.
  • Search your codebase or source control repository for the pattern UPDATE ... FROM ... WITH (NOLOCK) or DELETE ... FROM ... WITH (READUNCOMMITTED).

Step 2: Modify the T-SQL Syntax

  • Open the query in SQL Server Management Studio (SSMS) or Azure Data Studio.
  • Remove the WITH (NOLOCK) or WITH (READUNCOMMITTED) hint specifically from the target table reference in the UPDATE or DELETE clause.
  • If the hint was mistakenly intended for a joined table (not the target), ensure the hint is correctly placed only on the secondary table in the FROM clause, not the table being modified.
  • Example fix: Change UPDATE A SET A.Col = 1 FROM dbo.TableA A WITH (NOLOCK) WHERE... to UPDATE A SET A.Col = 1 FROM dbo.TableA A WHERE....

Step 3: Update Database Compatibility Level (If Applicable)

  • Navigate to SSMS > Object Explorer > Right-click Database > Properties > Options.
  • Verify the Compatibility Level is set to the latest version supported by SQL Server 2025 to ensure deprecation warnings are accurately logged.
  • If you are not ready to change application logic immediately, document the compatibility level setting, as older levels may suppress this specific warning but will not fix the underlying code debt.

Step 4: Deploy and Monitor

  • Push the corrected stored procedures or application code to your staging environment first.
  • Monitor the SQL Server Error Log on your Windows 11 or Windows Server 2025 instance for 24-48 hours to ensure Error 8350 no longer appears in the logs.

Alternative or Verification Steps

  • Verification: Re-run the specific query manually in SSMS after the edit; the deprecation warning (Severity 10, State 1) should no longer populate in the “Messages” tab.
  • Alternative: If removing the hint is not immediately feasible due to a third-party vendor application, use the SQL Server Deprecated Features Extended Events session to filter and suppress this specific alert in monitoring dashboards while you await a vendor patch.

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

Troubleshooting Guide: SQL Server Error 8351

Why This Error Happens

Error 8351 occurs when a trace control request—typically issued through Extended Events, SQL Trace, or a third-party monitoring tool—passes invalid or out-of-range parameters during event registration. This is commonly triggered by corrupted trace definition metadata, a mismatched SQL Server version between client tools and the server engine, or malformed GUIDs/channel values supplied by a custom trace session. It can also occur after an incomplete upgrade to SQL Server 2025 where legacy trace providers were not properly re-registered.

Step-by-Step Resolution Guide

Step 1: Verify Active Trace Sessions and Clear Stale Traces

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run the following query to inspect currently active traces:
SELECT * FROM sys.traces;
  • If a corrupted or orphaned trace is found, stop and remove it using:
EXEC sp_trace_setstatus @traceid = <id>, @status = 0;
EXEC sp_trace_setstatus @traceid = <id>, @status = 2;

Step 2: Validate Extended Events Session Configuration

  • Open Object Explorer > Management > Extended Events > Sessions.
  • Right-click the session throwing the error and select Script Session as > CREATE To > New Query Editor Window.
  • Inspect the script for invalid parameter values, especially in ADD EVENT or ADD TARGET clauses (e.g., incorrect max_memory, event_retention_mode, or invalid file path for file targets).
  • Correct any misconfigured values and re-deploy the session using DROP EVENT SESSION followed by CREATE EVENT SESSION.

Step 3: Re-register SQL Server Trace Providers

  • Open an elevated Command Prompt on Windows Server 2025 / Windows 11.
  • Navigate to the SQL Server binaries directory, typically:
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\
  • Re-register the trace provider DLL (sqlevn70.dll or equivalent) using:
regsvr32 sqlevn70.dll
  • Restart the SQL Server (MSSQLSERVER) service via services.msc to reload provider registrations.

Step 4: Check for Permission Issues on the Service Account

  • Open services.msc and confirm the SQL Server service is running under a valid domain or local service account.
  • Ensure this account has Log on as a service and Perform volume maintenance tasks rights via Local Security Policy > User Rights Assignment.
  • Grant the service account full control on the SQL Server log directory (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\) to prevent event registration failures caused by access denial.

Step 5: Apply the Latest Cumulative Update

  • Check the currently installed build number by running:
SELECT @@VERSION;
  • Compare against the latest Cumulative Update (CU) for SQL Server 2025 on the Microsoft Update Catalog.
  • Download and install the latest CU, then restart the server to ensure trace-related binaries are patched.

Alternative or Verification Steps

  • After applying fixes, re-run the original trace or Extended Events session and confirm Error 8351 no longer appears in the SQL Server Error Log (ERRORLOG file) or Windows Event Viewer > Applications and Services Logs.
  • If the issue persists, create a brand-new Extended Events session from scratch using the built-in “Quick Start” template in SSMS to rule out corrupted session XML as the root cause.

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

Troubleshooting Guide: SQL Server Error 8320 — @@REMSERVER Deprecation Warning

Why This Error Happens

This message is raised because @@REMSERVER is a legacy system function that Microsoft has formally marked as deprecated, meaning it is slated for removal in a future SQL Server release. SQL Server 2025 now surfaces this warning more aggressively (Error 8320) whenever the function is referenced in T-SQL batches, stored procedures, triggers, or linked server configurations. The root cause is almost always legacy code—often inherited from older SQL Server versions (2008/2012-era scripts)—that still relies on this function to identify the server name used by a client to connect, instead of using modern alternatives like SERVERPROPERTY('ServerName').

Step-by-Step Resolution Guide

Step 1: Identify All Instances of @@REMSERVER in Your Codebase

  • Run a search across your database objects using the following query to locate affected modules:
  SELECT OBJECT_NAME(object_id), definition 
  FROM sys.sql_modules 
  WHERE definition LIKE '%@@REMSERVER%';
  • Check linked server definitions, replication scripts, and legacy ETL packages (SSIS) that may also reference this function outside of standard stored procedures.
  • Review SQL Server Agent Job steps, as these are commonly overlooked sources of deprecated syntax.

Step 2: Replace Deprecated Syntax with Modern Equivalents

  • Open SQL Server Management Studio (SSMS) 21 (compatible with SQL Server 2025) and edit the identified stored procedures.
  • Replace @@REMSERVER references with SERVERPROPERTY('ServerName') or HOST_NAME(), depending on whether you need the server identity or the client workstation name.
  • Save and redeploy the updated stored procedures to your development environment first before pushing to production.

Step 3: Suppress or Monitor the Warning During Transition (Temporary Workaround)

  • If immediate code refactoring isn’t feasible, you can monitor the severity without halting execution, as Error 8320 is a warning-level event (not a blocking error).
  • Use SQL Server Configuration Manager on Windows Server 2025 to check the Error Log path (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\) and filter for Event ID 8320 to track frequency.
  • Update your SQL Server Agent alerts to flag this specific severity level so your team is notified without the application failing.

Step 4: Update Compatibility Level and Test

  • Navigate to the Database Properties in SSMS and verify the Compatibility Level is set appropriately for SQL Server 2025 (160 or higher) under the Options tab.
  • Run regression tests using the DBCC CHECKDB command alongside your application test suite to ensure removing @@REMSERVER didn’t break dependent logic.

Alternative or Verification Steps

  • To verify the fix, re-run the sys.sql_modules search query from Step 1; it should return zero rows once all instances are refactored.
  • As an alternative, if third-party vendor software is the source of the @@REMSERVER call and you cannot edit the source code, contact the vendor for a patch compatible with SQL Server 2025, or utilize a SQL Server Audit Specification to log occurrences without modifying the vendor’s binary.

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

Troubleshooting Guide: SQL Server Error 8319 – Kernel Object Already Exists

Why This Error Happens

This error occurs when the global kernel object (typically a shared memory section or named event used by SQL Server’s performance counter subsystem) already exists in the Windows session namespace but is owned by a different security principal than the current SQL Server service account. This commonly happens after changing the SQL Server service account, running multiple SQL Server instances with inconsistent permissions, or leftover kernel objects from a previous crashed or improperly terminated SQL Server process. Because the new service account cannot take ownership of the existing object, SQL Server disables performance counters rather than risk a security or access violation.

Step-by-Step Resolution Guide

Step 1: Verify the Current SQL Server Service Account

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Locate SQL Server (MSSQLSERVER) or the named instance (e.g., SQL Server (INSTANCENAME)).
  • Check the Log On As column to confirm which account is currently running the service.
  • Note this account name exactly (e.g., NT Service\MSSQLSERVER, a domain account, or a virtual account).

Step 2: Restart the SQL Server Service to Clear Stale Kernel Objects

  • Stop the SQL Server service completely:
net stop MSSQLSERVER
  • Confirm no orphaned sqlservr.exe processes remain in Task Manager under Details.
  • If a process is stuck, terminate it manually:
taskkill /F /IM sqlservr.exe
  • Restart the service to force Windows to recreate the kernel object under the correct account:
net start MSSQLSERVER

Step 3: Check and Correct Service Account Permissions

  • Open Local Security Policy (secpol.msc).
  • Navigate to Local Policies > User Rights Assignment.
  • Ensure the SQL Server service account has the following rights:
  • Log on as a service
  • Create global objects
  • If the account is missing these rights, add it manually and reboot the server.

Step 4: Rebuild Performance Counters (If Issue Persists)

  • Open an elevated Command Prompt.
  • Run the following to rebuild the Windows performance counter library:
lodctr /R
  • For SQL Server-specific counters, navigate to:
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\
  • Run:
unlodctr MSSQLSERVER
lodctr perf-MSSQLSERVER-sqlctr.ini

Step 5: Restart the Server as a Last Resort

  • If the kernel object persists across service restarts, perform a full OS restart.
  • This clears the Windows session namespace entirely, removing any orphaned kernel objects tied to the previous service account.

Alternative or Verification Steps

  • After applying fixes, open Performance Monitor (PerfMon) and confirm that SQLServer:General Statistics or related SQL counters are selectable and populating with live data.
  • Check the SQL Server Error Log (via SSMS or ERRORLOG file) to confirm Error 8319 no longer appears on service startup; if it persists, consider creating a brand-new service account and reassigning it via SQL Server Configuration Manager rather than reusing the conflicted one.

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

Why This Error Happens

This error occurs when the registry keys associated with SQL Server Performance Counters (under HKLM\SOFTWARE\Microsoft\...\Performance) are either corrupted, missing, or inaccessible due to insufficient permissions. It is commonly triggered after a Windows Server 2025 cumulative update or a SQL Server 2025 patch that modifies the registry hive structure without properly re-registering the performance DLLs. Additionally, the Network Service or SQL Server Service Account may lack the required read permissions on the specific registry path referenced in the error.

Step-by-Step Resolution Guide

Step 1: Verify Registry Permissions

  • Open regedit and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance.
  • Right-click the key, select Permissions, and ensure the SQL Server service account (e.g., NT Service\MSSQLSERVER) has Read access.
  • Check the exact key path mentioned in the error log (replace %ls placeholders with the actual values found in the SQL Server Error Log) to confirm it exists.

Step 2: Rebuild Performance Counters

  • Open Command Prompt as Administrator.
  • Run lodctr /R to rebuild the default performance counter registry values from the backup stored in the .ini files.
  • Restart the Windows Management Instrumentation (WMI) service via services.msc to ensure the counter cache refreshes correctly.

Step 3: Re-register SQL Server Specific Counters

  • Navigate to the SQL Server Binn directory, typically located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\.
  • Run the following command to unload and reload the specific SQL Server performance library: unlodctr MSSQLSERVER followed by lodctr perf-MSSQLSERVERsqlctr.ini.
  • Restart the SQL Server (MSSQLSERVER) service to apply the new counter configuration.

Step 4: Run System File Checker (SFC)

  • If the registry rebuild does not resolve the issue, corrupted system files might be preventing the registry write-back.
  • Run sfc /scannow in an elevated Command Prompt to repair underlying OS component dependencies required by the Performance Monitor.

Alternative or Verification Steps

  • Verification: Open Performance Monitor (perfmon.exe), attempt to add a counter from the “SQLServer:General Statistics” group. If the list populates without errors, the fix was successful.
  • Alternative: If counters remain disabled, use the exctrlst.exe (Extensible Counter List) tool to manually check the “Performance Counters Enabled” flag for the SQL Server service and set it to Yes if it reads “No.”

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

Troubleshooting Guide: SQL Server Error 8318 – Virtual Memory Allocation Failure During Performance Counters Initialization

Why This Error Happens

This error occurs when SQL Server 2025 is unable to allocate the required virtual memory address space to initialize its performance counters shared memory segment during startup. This is typically caused by virtual address space fragmentation, insufficient system resources, memory pressure from other applications, or a corrupted performance counter registry configuration. It can also occur when third-party security software or memory management tools interfere with SQL Server’s ability to reserve contiguous memory blocks at startup.

Step-by-Step Resolution Guide

Step 1: Rebuild the Performance Counter Registry Library

  • Open an elevated Command Prompt on Windows Server 2025 / Windows 11.
  • Run lodctr /R to rebuild the counter registry values from the backup stored in the registry.
  • Navigate to the SQL Server installation directory (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn) and run unlodctr MSSQLSERVER followed by lodctr perf-MSSQLSERVERsqlctr.ini to reload SQL Server-specific counters.
  • Restart the SQL Server (MSSQLSERVER) service afterward.

Step 2: Check for Virtual Address Space Fragmentation

  • Open Task Manager or Performance Monitor (perfmon.exe) and check the Process > Virtual Bytes and Private Bytes counters for sqlservr.exe.
  • Close unnecessary background applications or services consuming large contiguous memory blocks, especially antivirus or backup agents known to hook into process memory.
  • If running on a virtual machine, confirm the host has not overcommitted memory, and check Hyper-V/VMware dynamic memory settings.

Step 3: Review SQL Server Startup Parameters and Memory Configuration

  • Open SQL Server Configuration Manager and verify startup parameters under SQL Server Services > Properties > Startup Parameters.
  • Ensure -g (memory to reserve) parameter is not set too high, as this reduces available virtual address space for other SQL Server components, including performance counters.
  • If using Lock Pages in Memory, confirm the SQL Server service account has this permission correctly assigned via secpol.msc > Local Policies > User Rights Assignment.
  • Restart the SQL Server service and monitor the SQL Server Error Log for Error 8318 recurrence.

Step 4: Disable and Re-enable SQL Server Performance Counters Manually

  • Open Registry Editor (regedit) and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Performance.
  • Verify the Open, Collect, and Close DLL function references point to a valid, non-corrupted perf.dll or sqlctr.dll file in the Binn directory.
  • If entries are missing or corrupted, reinstall the SQL Server Database Engine performance monitoring component via SQL Server Setup > Repair.

Alternative or Verification Steps

  • After applying fixes, open Performance Monitor (perfmon.exe), click Add Counters, and confirm that SQLServer:General Statistics and related SQL counters now appear in the list without errors.
  • If the issue persists, check the SQL Server Error Log (ERRORLOG file in the Log folder) for Error 8318 recurrence and cross-reference with Windows Event Viewer System logs for related low-memory or resource exhaustion warnings (Event ID 2004 or 333).

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

Troubleshooting Guide: SQL Server Error 8316 – Cannot Open Registry Key ‘HKLM%ls’

Why This Error Happens

This error occurs when the SQL Server service account lacks sufficient permissions to read or write to the specific registry hive path reserved for performance counter definitions, typically under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\...\Performance. It can also result from a corrupted or missing registry key caused by an incomplete SQL Server installation, a failed patch/update, or third-party security software stripping registry permissions. In some cases, Windows Server 2025’s stricter default ACL inheritance settings cause the service account to lose access after an OS upgrade.

Step-by-Step Resolution Guide

Step 1: Verify the SQL Server Service Account

  • Open Services.msc and confirm which account is running the SQL Server (MSSQLSERVER) service.
  • Note the exact account name (e.g., NT Service\MSSQLSERVER or a domain service account).
  • Cross-check this against the account configured in SQL Server Configuration Manager.

Step 2: Grant Registry Permissions Manually

  • Open regedit.exe as Administrator.
  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\Performance (adjust instance name/version as needed).
  • Right-click the key, select Permissions, and add the SQL Server service account with Full Control.
  • Repeat this for the parent key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Performance.

Step 3: Rebuild Performance Counters via Command Line

  • Open an elevated Command Prompt.
  • Navigate to the Binn folder: cd "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn".
  • Run unlodctr MSSQLSERVER to remove the corrupted counter definitions.
  • Run lodctr perf-MSSQLSERVERsqlctr.ini to reload fresh counter definitions from the installation files.

Step 4: Restart SQL Server Services

  • Restart the SQL Server (MSSQLSERVER) service and the Windows Management Instrumentation (WMI) service via Services.msc.
  • Alternatively, run net stop MSSQLSERVER && net start MSSQLSERVER from an elevated Command Prompt.
  • Check the SQL Server Error Log immediately after restart for a repeat of Error 8316.

Alternative or Verification Steps

  • Open Performance Monitor (perfmon.exe), add a counter, and search for “SQL Server:General Statistics”—if it appears in the list, the fix was successful.
  • If the issue persists, run lodctr /R as Administrator to fully rebuild the entire Windows performance counter registry structure from scratch, then repeat Step 4.

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

Troubleshooting Guide: SQL Server Error 8314 — Performance Counters Disabled

Why This Error Happens

This error occurs when the SQL Server performance counter registry entries (DLL paths and counter definitions) stored under the Windows registry become corrupted, missing, or out of sync with the installed SQL Server build. It commonly happens after a failed service pack/cumulative update installation, an incomplete uninstall of a prior SQL Server instance, or registry permission restrictions that prevent SQL Server from registering its performance library (sqlctr*.dll) during startup. Because Windows Server 2025 and Windows 11 enforce stricter registry ACLs by default, the SQL Server service account may also lack the rights needed to read or rebuild these keys.

Step-by-Step Resolution Guide

Step 1: Verify the Scope of the Missing Performance Object

  • Check the SQL Server Error Log for the exact %ls object name referenced (e.g., SQLServer:Buffer Manager).
  • Open Registry Editor (regedit) and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\<InstanceID>\Performance.
  • Confirm whether the Library value correctly points to sqlctr160.dll (or the current build’s counter DLL) in the Binn folder.

Step 2: Rebuild Performance Counters Using lodctr

  • Open an elevated Command Prompt (Run as Administrator).
  • Navigate to the SQL Server Binn directory, typically: cd "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn"
  • Unload the corrupted counters: unlodctr MSSQLSERVER
  • Reload the counters using the instance’s configuration file: lodctr perfctr.ini (or lodctr /M:perfmmc.ini depending on build, found in the Binn folder).
  • Restart the SQL Server (MSSQLSERVER) service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.

Step 3: Repair Registry Permissions

  • Right-click the Performance registry key from Step 1 and select Permissions.
  • Ensure the SQL Server service account (e.g., NT Service\MSSQLSERVER) has Read and Query Value permissions.
  • If permissions are broken beyond repair, export the key as backup, delete it, and run Setup.exe /ACTION=REPAIR from the SQL Server installation media to regenerate the registry entries cleanly.

Step 4: Rebuild the Entire Windows Performance Counter Library (If Step 2 Fails)

  • Run the global rebuild commands in an elevated Command Prompt:
  • cd C:\Windows\System32
  • lodctr /R
  • Run the WMI/performance sync utility: winmgmt /resyncperf
  • Restart the server to fully reinitialize the Performance Counter DLL Host service.

Alternative or Verification Steps

  • Verify the fix: Open Performance Monitor (perfmon.exe), click the green “+” to add a counter, and confirm the SQL Server performance objects (e.g., SQLServer:Buffer Manager, SQLServer:General Statistics) now appear in the list without errors.
  • Alternative solution: If counters still fail to load, uninstall and cleanly reinstall the specific SQL Server Cumulative Update (CU) package, as this will force a fresh re-registration of all performance DLLs and registry keys.

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

Troubleshooting Guide: SQL Server Error 8315 – Performance Counter Not Found in Registry

Why This Error Happens

This error typically occurs when the performance counter registry entries for SQL Server 2025 have become corrupted, were not registered correctly during installation, or were overwritten by another application’s installer. It can also arise when the lodctr/unlodctr counter DLLs lose synchronization with the registry due to incomplete patching, failed Cumulative Updates, or insufficient administrative permissions during setup. In some cases, third-party monitoring tools or antivirus software interfere with the registry keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services, causing SQL Server to disable its performance counter subsystem entirely.

Step-by-Step Resolution Guide

Step 1: Verify Administrative Privileges and Service Account Permissions

  • Ensure you are running SQL Server services and any repair tools as a local Administrator.
  • Open an elevated Command Prompt (Run as Administrator) before executing any registry or counter commands.
  • Confirm the SQL Server service account has “Read” and “Write” access to HKLM\SYSTEM\CurrentControlSet\Services\PerfProc\Performance.

Step 2: Rebuild the Performance Counter Library

  • Navigate to the Binn folder, typically located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\.
  • Run the following command to unload the corrupted counters:
    unlodctr MSSQLSERVER
  • Immediately reload the counters using the installation XML definition file:
    lodctr /M:sqlctr.ini or run the batch file sqlctr160.bat if present (adjust version number for SQL Server 2025 build).
  • Restart the “Windows Management Instrumentation” service (winmgmt) to clear cached counter data.

Step 3: Re-register Counters via Instance-Aware Utility

  • For named or multiple instances, use the instance-specific registration tool: lodctr /M:perf-MSSQLSERVER-sqlctr.xml.
  • Locate this XML file in the Binn directory if the standard .ini method fails due to Unicode/XML formatting changes in SQL 2025.
  • Clear the “Last Counter” and “Last Help” values under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib if duplicate IDs are suspected, then re-run the load command.

Step 4: Restart Services and Validate Registry Integrity

  • Restart the SQL Server (MSSQLSERVER) service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.
  • Run sfc /scannow to rule out underlying Windows Server 2025 system file corruption affecting the Perflib subsystem.
  • Check the SQL Server Error Log for the absence of the 8315 error upon restart.

Alternative or Verification Steps

  • Open Performance Monitor (perfmon.exe), click the green “+” icon, and verify that “SQLServer:General Statistics” and other SQL-specific counter groups appear in the list without errors.
  • If the rebuild fails, run lodctr /R to perform a full rebuild of all system performance counter values from the system registry’s backup store, then repeat Step 2 specifically for the SQL Server counters.

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

Troubleshooting Guide: SQL Server Error 8313 – Performance Counter Mapping Failure

Why This Error Happens

Error 8313 occurs when the SQL Server performance counter registry entries become corrupted, out of sync, or are missing the necessary index-to-name mappings required by the Windows Performance Monitor subsystem. This is commonly triggered by an incomplete SQL Server upgrade/patch, a corrupted perf-MSSQLSERVER-*.ini or perf-MSSQLSERVER-*.h file, or insufficient registry permissions for the SQL Server service account. In some cases, third-party monitoring agents or antivirus software interfere with the registry keys under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLSERVER\Performance, causing the mapping to fail silently and disabling the counters entirely.

Step-by-Step Resolution Guide

Step 1: Verify the Current State of the Performance Counters

  • Open an elevated Command Prompt and run lodctr /q MSSQLSERVER to query the current loaded counter status.
  • Check the SQL Server Error Log (located by default at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for repeated 8313 entries to confirm this is an ongoing registry issue rather than a one-time startup race condition.
  • Open perfmon.msc and attempt to add an “SQLServer:General Statistics” counter — if it is missing from the list, this confirms the mapping failure.

Step 2: Rebuild the Windows Performance Counter Library

  • Run lodctr /r from an elevated Command Prompt to rebuild the base performance counter registry entries system-wide (this reads from the default .ini definitions and resets corrupted indexes).
  • Restart the Windows Management Instrumentation (WMI) service via services.msc or by running net stop winmgmt followed by net start winmgmt.
  • Reboot Windows Server 2025 / Windows 11 if the lodctr /r command returns an access denied or locked file error.

Step 3: Re-register the SQL Server-Specific Performance DLL

  • Navigate to the Binn directory, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\.
  • Locate sqlctr170.dll (version number may vary based on your SQL Server 2025 build) and re-register it using regsvr32 sqlctr170.dll.
  • Run unlodctr MSSQLSERVER followed by lodctr perf-MSSQLSERVER-sqlctr.ini from the same Binn directory to manually reload the SQL-specific counter mappings.

Step 4: Validate Registry Permissions

  • Open regedit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLSERVER\Performance.
  • Confirm the SQL Server service account (e.g., NT Service\MSSQLSERVER) has Read and Query Value permissions on this key and the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Performance key.
  • Grant Full Control temporarily if permissions appear restricted, then restart the SQL Server service to test.

Step 5: Restart Services and Confirm Resolution

  • Restart the SQL Server (MSSQLSERVER) service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.
  • Monitor the ERRORLOG file during startup to confirm Error 8313 no longer appears.

Alternative or Verification Steps

  • Open Performance Monitor (perfmon.msc), click the green “+” icon, and confirm that “SQLServer:Buffer Manager,” “SQLServer:General Statistics,” and other SQL-specific counter categories are now selectable and populating live data.
  • If the issue persists after rebuilding counters, run lodctr /R:perf-MSSQLSERVER-sqlctr.ini from the Binn directory as an alternative targeted rebuild, or consider a full repair installation of the SQL Server Database Engine component via the SQL Server Installation Center.

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

Troubleshooting Guide: SQL Server Error 8311 – Unable to Map View of File Mapping Object

Why This Error Happens

Error 8311 occurs when SQL Server 2025 cannot create or map a shared memory region used by the performance counters subsystem, typically because the memory-mapped file used by the perfmon infrastructure is corrupted, locked, or inaccessible. This is commonly caused by insufficient permissions on the SQL Server service account, a corrupted performance counter registry, or conflicts with another process (such as antivirus or monitoring software) holding a lock on the shared memory section. In some cases, it can also stem from an incomplete SQL Server installation/repair or stale counter DLLs left behind after an upgrade on Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Rebuild the Windows Performance Counter Library

  • Open an elevated Command Prompt on the Windows Server 2025 / Windows 11 host.
  • Run lodctr /R to rebuild the default performance counter registry values from the system backup stored in the registry.
  • Run unlodctr MSSQLSERVER followed by lodctr for the SQL Server-specific counter DLL (or the named instance equivalent, e.g., unlodctr MSSQL$INSTANCENAME).
  • Restart the Windows Management Instrumentation (WMI) service since it depends on the counter registry.

Step 2: Verify SQL Server Service Account Permissions

  • Open Services.msc and confirm which account is running the SQL Server (MSSQLSERVER) service.
  • Ensure this account has “Log on as a service” rights via secpol.msc → Local Policies → User Rights Assignment.
  • Grant the service account full control on C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\ and the %SystemRoot%\System32\ performance counter files (sqlctr.dll / sqlctr160.dll or newer equivalent for SQL 2025).
  • Restart the SQL Server service and check if Error 8311 persists in the SQL Server Error Log.

Step 3: Check for Memory-Mapped File Conflicts

  • Use Process Explorer (Sysinternals) to search for open handles to Global\MSSQL$<InstanceName> or similar shared memory sections.
  • Identify any third-party process (antivirus, backup agent, or monitoring tool) locking this handle and add an exclusion for sqlservr.exe and the SQL Server data/log directories.
  • Temporarily disable third-party antivirus real-time scanning and attempt a SQL Server service restart to confirm if the lock is released.

Step 4: Reinstall or Repair SQL Server Performance Counters

  • If Steps 1–3 do not resolve the issue, run the SQL Server 2025 Setup media and select Repair for the instance exhibiting the error.
  • During repair, ensure the “Performance Counter” feature is re-registered; this regenerates sqlctr.ini and recompiles counter definitions.
  • After repair completes, reboot the Windows Server 2025 host to clear any stale shared memory handles before restarting SQL Server.

Alternative or Verification Steps

  • Verify the fix by opening Performance Monitor (perfmon.exe) and confirming that SQL Server-specific counter objects (e.g., SQLServer:Buffer Manager, SQLServer:General Statistics) appear and populate with live data.
  • As an alternative, if counters remain disabled, use exec sp_configure 'show advanced options', 1; reconfigure; to confirm SQL Server configuration isn’t blocking counter initialization, or check Event Viewer → Application log for correlating errors (Event ID 8311) pointing to a specific DLL version mismatch.

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

Troubleshooting Guide: SQL Server Error 8312 – Cannot Create Named Mutex

Why This Error Happens

Error 8312 occurs when SQL Server 2025 fails to create or open a named mutex object used for managing performance counter synchronization. This is typically caused by insufficient permissions on the Global\ namespace (often due to restrictive Group Policy or security software), a corrupted or conflicting kernel object left behind by an unclean shutdown, or another process/instance holding a lock on an identically named mutex. In most cases, this stems from the SQL Server service account lacking rights to create objects in the global object namespace on Windows Server 2025 or Windows 11.

Step-by-Step Resolution Guide

Step 1: Verify SQL Server Service Account Permissions

  • Open Local Security Policy (secpol.msc) on the host machine.
  • Navigate to Security Settings > Local Policies > User Rights Assignment.
  • Locate “Create global objects” and confirm the SQL Server service account (e.g., NT Service\MSSQLSERVER) is listed.
  • If missing, add the account, click Apply, then restart the SQL Server service via services.msc.

Step 2: Rebuild Performance Counter Registry Entries

  • Open an elevated Command Prompt and run:
  lodctr /R
  • This rebuilds the default performance counter registry values from the stored INI files.
  • Follow this by re-registering SQL Server-specific counters:
  cd "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn"
  unlodctr MSSQLSERVER
  lodctr perf-MSSQLSERVER-sqlctr.ini
  • Restart the SQL Server (MSSQLSERVER) service afterward.

Step 3: Check for Orphaned Mutex Handles or Conflicting Processes

  • Use Sysinternals Process Explorer to search (Find > Find Handle or DLL) for the specific mutex name referenced in the error (%ls placeholder in Event Viewer).
  • If a stale handle is found tied to a non-SQL process, terminate that process safely.
  • Reboot the server if the handle cannot be released manually, as this clears all kernel object locks.

Step 4: Disable Conflicting Security Software Temporarily

  • Some endpoint protection or sandboxing tools intercept Global\ namespace object creation.
  • Temporarily disable third-party antivirus/EDR software and attempt to start the SQL Server service again.
  • If the service starts successfully, add an exclusion rule for sqlservr.exe in the security software’s configuration.

Alternative or Verification Steps

  • Open Performance Monitor (perfmon.exe) and attempt to add an SQLServer:General Statistics counter; if it populates with live data, the mutex and counter registration are functioning correctly.
  • If the issue persists, reinstall the SQL Server instance’s performance counter DLLs using the SQL Server Installation Center’s Repair option, which resets corrupted counter definitions without affecting databases.

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

Why This Error Happens

Error 8310 occurs when SQL Server 2025 cannot create or open a named shared memory file mapping object, which is required to initialize its performance counters (Perfmon objects) at startup. This typically results from insufficient permissions on the registry or shared memory namespace, a corrupted Performance Library (Perflib) registration, or a conflict caused by another process/instance holding a lock on the same named object. It can also occur when the SQL Server service account lacks rights to the Global\ object namespace in Windows Server 2025 / Windows 11 due to restrictive Group Policy or security software interference.

Step-by-Step Resolution Guide

Step 1: Verify Service Account Permissions

  • Open Services.msc and confirm the account running SQL Server (e.g., NT Service\MSSQLSERVER).
  • Ensure this account has the “Create global objects” user right.
  • Navigate to secpol.msc → Local Policies → User Rights Assignment → “Create global objects” and add the SQL Server service account if missing.
  • Restart the SQL Server service after applying changes.

Step 2: Rebuild Performance Counter Library

  • Open an elevated Command Prompt and navigate to C:\Windows\System32.
  • Run lodctr /R to rebuild the default Windows performance counter registry values.
  • For SQL Server–specific counters, navigate to the Binn folder (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn).
  • Run unlodctr MSSQLSERVER followed by lodctr perf-MSSQLSERVERsqlctr.ini to reload the counters cleanly.

Step 3: Check for Object Namespace Conflicts

  • Use Process Explorer (Sysinternals) and search the handle list for the exact object name referenced in the error (%ls).
  • Identify if another process, antivirus, or a duplicate SQL instance is locking the same named mapping object.
  • Terminate or reconfigure the conflicting process, or rename the instance if duplicate GUIDs are causing collisions.

Step 4: Restart SQL Server Services in Correct Order

  • Stop all SQL Server related services: SQL Server Agent, SQL Server Browser, and the Database Engine.
  • Clear any orphaned shared memory sessions by restarting the server if the issue persists after stopping services.
  • Start the Database Engine first, then dependent services, allowing each to fully initialize before starting the next.

Alternative or Verification Steps

  • Open Performance Monitor (Perfmon) and attempt to add counters under the “SQLServer:General Statistics” object; if they appear and populate with live data, the fix was successful.
  • If the error persists, run SQL Server Setup in Repair mode from the installation media to restore corrupted performance DLL registrations without a full reinstall.

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

Troubleshooting Guide: SQL Server Error 8308 (USER_ID Deprecation Warning)

Why This Error Happens

Error 8308 is raised because the USER_ID() function, along with related legacy security metadata functions, has been marked as deprecated and is slated for removal in a future SQL Server release. This typically occurs when legacy T-SQL scripts, old stored procedures, or third-party applications ported from older SQL Server versions (2008/2012-era code) still reference USER_ID to resolve security identifiers instead of modern catalog views. SQL Server 2025 flags this via the Deprecation Announcement Extended Event or SQL Server error log to warn administrators before the feature is fully removed.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the Deprecated Call

  • Open SQL Server Management Studio (SSMS) and connect to the instance reporting the error.
  • Run the following query against the system_health Extended Events session to locate which database/object triggered the warning:
  SELECT object_name, CAST(event_data AS XML) AS EventData
  FROM sys.fn_xe_file_target_read_file('system_health*.xel', NULL, NULL, NULL)
  WHERE object_name = 'deprecation_announcement';
  • Cross-reference the EventData XML output for USER_ID to pinpoint the stored procedure, view, or application connection string causing the call.

Step 2: Replace Legacy Function Calls

  • Open the identified stored procedure or script file (commonly located in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Jobs\ for SQL Agent jobs, or within application source code).
  • Replace any instance of USER_ID('username') with the modern equivalent using the sys.database_principals catalog view:
  SELECT principal_id FROM sys.database_principals WHERE name = 'username';
  • Save and redeploy the updated script to your development, staging, and production environments.

Step 3: Audit Linked Servers and Third-Party Tools

  • Check any linked server configurations or ORM frameworks (Entity Framework, Hibernate, etc.) that may generate dynamic SQL using USER_ID.
  • Update driver versions (ODBC 18+ or OLE DB 19+) on Windows Server 2025 / Windows 11, as newer drivers avoid generating deprecated syntax automatically.
  • Re-run application regression tests to confirm no remaining dependencies trigger Error 8308.

Step 4: Suppress Logging Noise (Temporary Workaround)

  • If immediate code remediation isn’t feasible, suppress the specific trace flag logging to prevent log flooding while refactoring is scheduled.
  • Use the following command cautiously, only as a short-term measure:
  DBCC TRACEOFF (8308, -1);
  • Document this trace flag change in your change-management system, as it must be reverted once code fixes are deployed.

Alternative or Verification Steps

  • Verify the Fix: Re-run the original stored procedure or application workflow and confirm Error 8308 no longer appears in the SQL Server Error Log (SQL Server Logs folder in SSMS Object Explorer) or the Windows Event Viewer under Applications and Services Logs > MSSQLSERVER.
  • Alternative Approach: If refactoring all instances is not immediately possible, enable Compatibility Level 150 or lower temporarily via ALTER DATABASE [YourDB] SET COMPATIBILITY_LEVEL = 150; to suppress deprecation enforcement while you complete the migration plan—note this is only a stopgap, as the feature will eventually be removed entirely.

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

Troubleshooting Guide: Error 8309 – BACKUP LOG WITH TRUNCATEONLY or WITH NOLOG is Deprecated

Why This Error Happens

This error occurs because BACKUP LOG WITH TRUNCATE_ONLY and WITH NO_LOG syntax has been deprecated since SQL Server 2008 and is no longer supported in SQL Server 2025. Scripts, maintenance plans, or legacy automation jobs that still reference this outdated syntax will fail because the engine no longer recognizes these options as valid log management commands. The underlying issue is almost always a database configured in FULL or BULK_LOGGED recovery model combined with legacy T-SQL that assumes manual log truncation is still possible via this method.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the Deprecated Command

  • Check SQL Server Agent Jobs under SQL Server Management Studio (SSMS) > SQL Server Agent > Jobs for any step containing TRUNCATE_ONLY or NO_LOG.
  • Search Maintenance Plans (msdb.dbo.sysmaintplan_subplans) and any custom PowerShell/T-SQL automation scripts stored in C:\Scripts\ or deployment pipelines.
  • Run the following query to scan recent job history for the error:
  SELECT * FROM msdb.dbo.sysjobhistory WHERE message LIKE '%TRUNCATE_ONLY%' OR message LIKE '%NO_LOG%';

Step 2: Switch the Database to Simple Recovery Model (If Log Truncation is the Goal)

  • Open SSMS, right-click the target database, select Properties > Options.
  • Under Recovery Model, change from Full or Bulk-logged to Simple.
  • Alternatively, execute via T-SQL:
  ALTER DATABASE [YourDatabaseName] SET RECOVERY SIMPLE;
  • This allows SQL Server to automatically truncate the inactive portion of the transaction log after each checkpoint, removing the need for manual intervention.

Step 3: Replace Deprecated Scripts with Supported Backup Syntax

  • If the database must remain in FULL recovery (e.g., for point-in-time restore requirements), replace the deprecated command with a proper log backup:
  BACKUP LOG [YourDatabaseName] TO DISK = 'C:\SQLBackups\YourDatabaseName_Log.trn';
  • Update any Maintenance Plan “Back Up Database (Transaction Log)” tasks to point to a valid UNC or local disk path with sufficient storage.
  • Ensure the SQL Server Service Account has write permissions to the backup directory (right-click folder > Properties > Security > Edit).

Step 4: Rebuild or Shrink the Transaction Log (If Log File Has Grown Too Large)

  • After switching to Simple recovery or performing a proper log backup, shrink the oversized log file:
  DBCC SHRINKFILE (YourDatabaseName_Log, 1);
  • Verify log file size via File Explorer at the default path C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.

Alternative or Verification Steps

  • Verify the fix by re-running the previously failing job or script; check msdb.dbo.sysjobhistory to confirm successful completion without Error 8309.
  • If FULL recovery must be retained for compliance reasons, configure a recurring Transaction Log Backup job (every 15–30 minutes) via SQL Server Agent instead of relying on manual truncation methods.

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

Troubleshooting Guide: SQL Server Error 8307 – FILE_ID Deprecation Warning

Why This Error Happens

Error 8307 occurs because the FILE_ID() function (and related file-id-based metadata references) has been marked as deprecated in SQL Server 2025 and is scheduled for removal in a future release. This warning is typically triggered when legacy T-SQL scripts, stored procedures, views, or third-party tools reference FILE_ID to resolve database file identifiers instead of using the modern catalog views. It is not a functional failure—the query still executes—but SQL Server raises this informational error to flag non-compliant code before backward compatibility is fully dropped.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the FILE_ID Reference

  • Search all stored procedures, functions, views, and application connection strings for FILE_ID( using SQL Server Management Studio (SSMS) “Find in Object Definitions.”
  • Run the following query to scan system metadata for dependent objects:
  SELECT OBJECT_NAME(object_id), definition
  FROM sys.sql_modules
  WHERE definition LIKE '%FILE_ID%';
  • Check SQL Server Agent jobs and SSIS packages, as these are common hidden sources of deprecated function calls.

Step 2: Replace FILE_ID with Modern Catalog Views

  • Update code to use sys.database_files or sys.master_files instead of FILE_ID().
  • Example replacement:
  -- Deprecated
  SELECT FILE_ID('MyDataFile');

  -- Recommended
  SELECT file_id FROM sys.database_files WHERE name = 'MyDataFile';
  • If referencing files across multiple databases, use sys.master_files with the database_id filter instead.

Step 3: Suppress or Monitor the Deprecation Warning Temporarily

  • While migrating code, use Extended Events to track exactly when/where the deprecated feature fires:
  CREATE EVENT SESSION [Track_FileID_Deprecation] ON SERVER
  ADD EVENT sqlserver.deprecation_announcement
  ADD TARGET package0.event_file(SET filename=N'C:\SQLLogs\FileIDDeprecation.xel');
  GO
  ALTER EVENT SESSION [Track_FileID_Deprecation] ON SERVER STATE = START;
  • Review the .xel output in SSMS to confirm all instances have been remediated before the next major SQL Server upgrade.

Step 4: Update Application and ORM Layers

  • If using Entity Framework, Dapper, or other ORMs on Windows Server 2025 / Windows 11 client machines, check generated SQL for implicit FILE_ID calls in migration scripts.
  • Redeploy updated application binaries and connection logic once T-SQL changes are validated in a staging environment.

Alternative or Verification Steps

  • Re-run the Extended Events session from Step 3 after deployment; a clean trace with zero deprecation_announcement events confirms the fix.
  • As a quick validation, execute sp_configure 'contained database authentication' alongside a manual test query using sys.database_files to confirm no error 8307 appears in the SQL Server Error Log (Management > SQL Server Logs in SSMS).

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

Troubleshooting Guide: SQL Server Error 8306 — Invalid level0type Value in sp_addextendedproperty

Why This Error Happens

This error occurs because the @level0type parameter in sp_addextendedproperty was supplied with an invalid or incorrectly cased value such as 'TYPE', which is not a recognized object class at the schema level. SQL Server 2025 requires @level0type to be one of a strict set of accepted values (e.g., 'SCHEMA'), and anything outside that enumerated list—including minor typos or deprecated keywords from older scripts—triggers Error 8306. This is typically caused by migrated or legacy scripts that used object-type names valid in earlier SQL Server versions or custom tooling, which are no longer (or were never) valid at that property level.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Statement

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and locate the exact sp_addextendedproperty call that is failing.
  • Check the error message detail in the Messages pane for the exact value passed (e.g., 'TYPE').
  • Review any deployment or migration scripts (.sql files) that may have auto-generated this call, especially ones ported from SQL Server 2008/2012-era tooling.

Step 2: Correct the level0type Value

  • Replace the invalid 'TYPE' value with a correct, supported object class. In almost all cases at the top level, this should be 'SCHEMA'.
  • Example corrected syntax:
  EXEC sp_addextendedproperty 
      @name = N'MS_Description', 
      @value = N'Sample description', 
      @level0type = N'SCHEMA', 
      @level0name = N'dbo';
  • Confirm that @level1type and @level2type (if used) also match valid values such as 'TABLE', 'COLUMN', or 'VIEW'.

Step 3: Validate Object Hierarchy Syntax

  • Cross-reference your statement against the official hierarchy: @level0type = 'SCHEMA' → @level1type = 'TABLE'/'VIEW'/'PROCEDURE' → @level2type = 'COLUMN'/'INDEX'/'PARAMETER'.
  • Ensure there are no extra quotes, trailing spaces, or incorrect casing in the parameter strings (SQL Server 2025 parses these as literal string matches).
  • Update any stored procedures or automation scripts (PowerShell, SSDT, Flyway, etc.) that dynamically generate these calls to pull from a validated list of object types.

Step 4: Re-run the Script in a Test Environment

  • Execute the corrected script against a non-production database first.
  • Use sys.extended_properties to confirm the property was created successfully:
  SELECT * FROM sys.extended_properties 
  WHERE class_desc = 'SCHEMA';

Alternative or Verification Steps

  • Run SELECT * FROM fn_listextendedproperty(NULL, 'SCHEMA', 'dbo', NULL, NULL, NULL, NULL); to verify the extended property now appears correctly against the schema.
  • If the error persists in automated deployment pipelines, check whether a third-party schema comparison or documentation tool (e.g., Redgate, ApexSQL) generated the script with outdated syntax, and update the tool to the latest SQL Server 2025–compatible version.

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

Troubleshooting Guide: SQL Server Error 8304 – INDEXKEY_PROPERTY Deprecation Warning

Why This Error Happens

Error 8304 is raised because INDEXKEY_PROPERTY has been marked as a deprecated feature in SQL Server 2025, and Microsoft has configured the Database Engine to emit this warning whenever the function is invoked in a query, stored procedure, view, or script. This occurs because legacy T-SQL code (often inherited from maintenance scripts, monitoring tools, or third-party database utilities) still references this function to retrieve index key column properties. The root cause is not a system failure but a compatibility-level flag that triggers deprecation tracking, which SQL Server uses to warn administrators before the feature is fully removed in a future release.

Step-by-Step Resolution Guide

Step 1: Identify All References to INDEXKEY_PROPERTY

  • Run a search across your database objects using the following query to locate affected code:
  • SELECT OBJECT_NAME(object_id), definition FROM sys.sql_modules WHERE definition LIKE '%INDEXKEY_PROPERTY%';
  • Check SQL Server Agent jobs, SSIS packages, and linked server scripts, as these are common hiding places for deprecated function calls.
  • Document every object that returns a match so you can prioritize remediation.

Step 2: Replace INDEXKEY_PROPERTY with Supported Catalog Views

  • Migrate existing logic to use sys.index_columns joined with sys.columns and sys.indexes, which provide the same metadata without triggering deprecation warnings.
  • Example replacement query:
  • SELECT i.name AS IndexName, c.name AS ColumnName, ic.key_ordinal, ic.is_descending_key FROM sys.indexes i INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id;
  • Update any application-layer ORM mappings or reporting views that depend on the old function syntax.

Step 3: Enable Deprecation Feature Tracking (Optional Monitoring)

  • Use Extended Events to confirm whether the warning still fires after code changes, by creating a session targeting the deprecation_announcement event.
  • Navigate to SQL Server Management Studio (SSMS) > Management > Extended Events > New Session, and filter on object_name = INDEXKEY_PROPERTY.
  • Let the session run for 24–48 hours in a staging environment to catch any missed references before deploying to production on Windows Server 2025.

Step 4: Update Compatibility Level and Re-test

  • Check your current database compatibility level by running SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • If the database is running at a lower compatibility level, consider updating it incrementally (e.g., 150 to 160) using ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 160; to align with SQL Server 2025 best practices, which often surfaces additional deprecated features earlier.
  • Re-run your regression test suite against all stored procedures and views after the compatibility change.

Alternative or Verification Steps

  • Confirm the fix by re-executing the original queries that previously generated Error 8304 and verifying the warning no longer appears in the SSMS Messages tab or the SQL Server Error Log (located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG by default).
  • As an alternative if full replacement isn’t immediately feasible, suppress non-critical deprecation noise temporarily by filtering Error 8304 in your monitoring/alerting tool (e.g., SQL Server Agent alerts or SCOM), while scheduling a formal code remediation sprint before the next major SQL Server upgrade.

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

Troubleshooting Guide: SQL Server Error 8305 — “TEXT IN ROW” Deprecation Warning

Why This Error Happens

This message appears because the text in row table option, enabled through the sp_tableoption system stored procedure, is a legacy feature tied to the deprecated text, ntext, and image data types. Microsoft flagged this feature for removal years ago, and in SQL Server 2025, the engine now raises Error 8305 more aggressively whenever a database or application attempts to invoke this option, even in compatibility mode. The root cause is almost always legacy T-SQL scripts, ORM-generated schemas, or older database backups/migrations that still reference deprecated LOB (Large Object) storage configurations instead of the modern varchar(max), nvarchar(max), or varbinary(max) types with the FILESTREAM or in-row storage attributes.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the Call

  • Open SQL Server Management Studio (SSMS) 21 (compatible with SQL Server 2025) and run a trace or check the Deprecation Features Extended Event session to capture which script, job, or application is calling sp_tableoption @OptionName = 'text in row'.
  • Query sys.dm_os_performance_counters or use the built-in XEvent deprecation_announcement to pinpoint the offending object:
  SELECT * FROM sys.fn_trace_gettable('C:\Logs\deprecation_trace.trc', default);
  • Check legacy migration scripts, SSIS packages, or third-party vendor software that may hardcode this call during database provisioning.

Step 2: Audit and Convert Legacy Data Types

  • Run the following query to find any tables still using deprecated LOB types that rely on the text in row option:
  SELECT t.name AS TableName, c.name AS ColumnName, ty.name AS DataType
  FROM sys.columns c
  JOIN sys.tables t ON c.object_id = t.object_id
  JOIN sys.types ty ON c.user_type_id = ty.user_type_id
  WHERE ty.name IN ('text', 'ntext', 'image');
  • Convert these columns to their modern equivalents using ALTER TABLE:
  ALTER TABLE dbo.YourTable ALTER COLUMN YourColumn VARCHAR(MAX);
  • Update any application connection strings or ORM mappings (Entity Framework, Dapper, etc.) to reflect the new data types.

Step 3: Remove or Replace the sp_tableoption Call

  • Locate the exact script or stored procedure invoking sp_tableoption 'tablename', 'text in row', 'ON' (or a numeric row-size value).
  • Comment out or delete this call entirely from deployment scripts, DACPAC projects, and database project files (.sqlproj) stored in C:\Projects\YourDB\Scripts\.
  • If the application genuinely requires inline LOB storage behavior, replace it with the (MAX) data types above, which handle in-row/off-row storage automatically based on the 8,000-byte threshold—no manual configuration needed.

Step 4: Apply Database Compatibility Level Updates

  • Ensure the database is running under compatibility level 170 (SQL Server 2025) via SSMS: Right-click Database → Properties → Options → Compatibility Level.
  • Alternatively, run:
  ALTER DATABASE YourDatabase SET COMPATIBILITY_LEVEL = 170;
  • This ensures the engine enforces modern storage behaviors and surfaces any remaining legacy dependencies clearly during testing.

Alternative or Verification Steps

  • Re-run the Extended Events deprecation session after applying fixes; confirm no further text in row events are logged over a 24-48 hour monitoring window.
  • If third-party software is the source and cannot be modified, suppress the warning at the application level by wrapping the call in a TRY...CATCH block and logging it for future vendor patch tracking, rather than relying on SQL Server to silently support the feature long-term.

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

Troubleshooting Guide: Error 8303 – CREATE DEFAULT and DROP DEFAULT Deprecation Warning

Why This Error Happens

This message appears because CREATE DEFAULT and DROP DEFAULT are legacy T-SQL statements that Microsoft has marked for deprecation in favor of the modern DEFAULT constraint syntax used within CREATE TABLE or ALTER TABLE. SQL Server 2025 still supports these legacy objects for backward compatibility, but it raises Error 8303 as a warning every time the statement is executed to alert developers that the feature will be removed in a future release. This is not a functional failure—your code will still run—but it indicates technical debt in your schema or scripts that relies on outdated object-binding mechanisms (default objects bound via sp_bindefault) rather than inline column constraints.

Step-by-Step Resolution Guide

Step 1: Identify All Legacy DEFAULT Objects in the Database

  • Run the following query to locate legacy default objects currently in use:
  SELECT name, type_desc FROM sys.objects WHERE type = 'D' AND is_ms_shipped = 0;
  • Cross-reference with sys.sql_expression_dependencies to find which tables/columns are bound to these defaults via sp_bindefault.
  • Search your .sql script files and stored procedures (using a tool like grep or VS Code’s “Find in Files”) for the literal strings CREATE DEFAULT and DROP DEFAULT.

Step 2: Migrate to Inline DEFAULT Constraints

  • For each legacy default object found, rewrite the logic using the modern syntax. For example, replace:
  CREATE DEFAULT dflt_Status AS 'Active';
  sp_bindefault 'dflt_Status', 'Employees.Status';

with:

  ALTER TABLE Employees ADD CONSTRAINT DF_Employees_Status DEFAULT 'Active' FOR Status;
  • Ensure the new constraint is named explicitly (e.g., DF_TableName_ColumnName) for easier future auditing.

Step 3: Unbind and Drop the Legacy Default Objects

  • Before dropping, unbind the default from the column using:
  EXEC sp_unbindefault 'Employees.Status';
  • Once unbound and the new constraint is confirmed active, remove the legacy object:
  DROP DEFAULT dflt_Status;
  • Avoid wrapping this in automated deployment scripts going forward—update your DACPAC/SSDT project templates to flag CREATE DEFAULT usage during build validation.

Step 4: Update SSDT Projects and CI/CD Pipelines

  • If using SQL Server Data Tools (SSDT) on Windows 11 or build agents on Windows Server 2025, update the .sqlproj schema compare settings to exclude legacy default objects from future scaffolding.
  • Re-run Database Project Build to confirm no new warnings (Error 8303) are generated in the build output window.

Alternative or Verification Steps

  • Verify the fix by re-executing the original script or stored procedure in SQL Server Management Studio (SSMS) 21+; the Messages tab should no longer display Error 8303.
  • As an alternative if large-scale refactoring isn’t immediately feasible, suppress the warning temporarily in non-production environments only by wrapping the statement in SET ANSI_WARNINGS OFF, though this is not a permanent fix and should be tracked as technical debt for remediation before upgrading to the next major SQL Server version.

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

Troubleshooting Guide: SQL Server Error 8302 — CREATE RULE / DROP RULE Deprecation Warning

Why This Error Happens

This message is a deprecation warning, not a functional failure, triggered because SQL Server 2025 has flagged CREATE RULE and DROP RULE as legacy T-SQL features scheduled for removal in a future release. The root cause is typically existing database schema, stored procedures, or legacy application code that still relies on rule-based data validation instead of the modern CHECK constraint model. It commonly surfaces during database migrations, schema deployments, or compatibility-level upgrades on Windows Server 2025 / Windows 11 environments where older databases are restored into newer SQL Server instances.

Step-by-Step Resolution Guide

Step 1: Identify All Usages of CREATE RULE / DROP RULE

  • Run the following query against your target database to locate legacy rule objects:
  SELECT name, object_id, type_desc 
  FROM sys.objects 
  WHERE type = 'R';
  • Check stored procedures, triggers, and deployment scripts (.sql files) in your source control repository for the keywords CREATE RULE and DROP RULE.
  • Note the table and column bindings using sp_help 'RuleName' to understand dependency scope.

Step 2: Migrate Rules to CHECK Constraints

  • For each identified rule, translate the logic into an equivalent CHECK constraint. Example:
  -- Old (deprecated)
  CREATE RULE salary_rule AS @salary >= 0;

  -- New (recommended)
  ALTER TABLE Employees 
  ADD CONSTRAINT CK_Salary CHECK (Salary >= 0);
  • Unbind the old rule first using sp_unbindrule 'TableName.ColumnName' before dropping it.
  • Drop the legacy rule object with DROP RULE salary_rule; once the new constraint is verified.

Step 3: Update Deployment Scripts and CI/CD Pipelines

  • Edit any .sql deployment files, DACPAC projects, or Flyway/Liquibase migration scripts to remove CREATE RULE/DROP RULE statements.
  • If using SQL Server Data Tools (SSDT) on Windows 11, rebuild the project after removing rule references to avoid schema compare warnings.
  • Re-run deployment in a staging environment first to confirm Error 8302 no longer appears in the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).

Step 4: Suppress the Warning Temporarily (If Immediate Migration Isn’t Feasible)

  • If you need more time to refactor, acknowledge that this is only a warning (Severity 10) and will not block execution in SQL Server 2025.
  • Use SET NOCOUNT ON; combined with application-level logging filters to suppress the message from cluttering logs until migration is complete.
  • Document the technical debt in your backlog with a target removal date, since future SQL Server versions will hard-fail on these statements.

Alternative or Verification Steps

  • Verify the fix by re-running your deployment script or stored procedure execution and confirming Error 8302 no longer appears in SSMS Messages tab or the Windows Event Viewer under Applications and Services Logs > MSSQLSERVER.
  • As an alternative, run DBCC USEROPTIONS and check database compatibility level via SELECT compatibility_level FROM sys.databases WHERE name = 'YourDB'; — ensure it’s set to the latest level (170) to fully validate that legacy rule-based objects are properly flagged for review.

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

Troubleshooting Guide: SQL Server Error 8199 – “In EXECUTE… Getting Data”

Why This Error Happens

Error 8199 typically occurs when SQL Server 2025 attempts to execute a stored procedure, dynamic SQL statement, or linked server query but encounters a permissions mismatch or context-switching failure during the EXECUTE AS operation. This is often triggered by corrupted security tokens, missing IMPERSONATE permissions on the target login/user, or an inability to retrieve data from a linked server/external source due to broken credential mapping. In Windows Server 2025 environments, this can also stem from Kerberos authentication failures when double-hop scenarios are involved.

Step-by-Step Resolution Guide

Step 1: Verify EXECUTE AS Permissions

  • Open SQL Server Management Studio (SSMS) and connect to the instance via an account with sysadmin privileges.
  • Run the following query to check if the calling user has impersonation rights:
  SELECT * FROM sys.server_permissions WHERE type = 'IM';
  • If missing, grant impersonation using: GRANT IMPERSONATE ON LOGIN::[TargetLogin] TO [CallingLogin];

Step 2: Check Linked Server and Provider Configuration

  • Navigate to Server Objects > Linked Servers in SSMS and verify the data source is reachable.
  • Confirm the “Security” tab settings use “Be made using this security context” rather than defaulting to anonymous logins.
  • Test connectivity manually using: EXEC sp_testlinkedserver 'YourLinkedServerName';

Step 3: Repair Corrupted Authentication Tokens

  • Restart the SQL Server (MSSQLSERVER) service via services.msc on Windows Server 2025 to flush stale security tokens.
  • Clear the Kerberos ticket cache on the client machine using the command: klist purge.
  • Re-register the Service Principal Name (SPN) if using domain accounts: setspn -L SQLServiceAccount.

Step 4: Validate Stored Procedure Context

  • Open the specific stored procedure causing the error in the Object Explorer.
  • Ensure the EXECUTE AS clause (e.g., EXECUTE AS OWNER or EXECUTE AS 'User') references a valid, non-orphaned user account within the database.
  • Run sp_change_users_login 'Report'; to detect and fix orphaned users if necessary.

Alternative or Verification Steps

  • Verification: Re-run the original query or stored procedure in a new SSMS query window; monitor the SQL Server Error Log (via EXEC sp_readerrorlog;) to confirm Error 8199 no longer appears.
  • Alternative: If the error persists specifically with linked servers, bypass the EXECUTE AS context entirely by using OPENQUERY syntax instead of standard distributed queries to force a direct connection.

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

Troubleshooting Guide: SQL Server Error 8301 – Invalid Level0type ‘USER’

Why This Error Happens

Error 8301 occurs because sp_addextendedproperty does not recognize 'USER' as a valid value for the @level0type parameter in SQL Server 2025. This typically happens when scripts are migrated from an older context or written based on incorrect documentation, as the valid object type for schema-level user objects is actually 'SCHEMA', not 'USER'. The procedure enforces a strict internal lookup table of valid level types, and 'USER' does not map to a recognized catalog object class at the level0 hierarchy.

Step-by-Step Resolution Guide

Step 1: Identify the Failing T-SQL Statement

  • Open the script or stored procedure that triggered Error 8301 in SQL Server Management Studio (SSMS) connected to your SQL Server 2025 instance.
  • Locate the exact call to sp_addextendedproperty and inspect the @level0type and @level0name parameters.
  • Example of the incorrect syntax: @level0type = N'USER', @level0name = N'dbo'

Step 2: Correct the Level0type Parameter

  • Replace 'USER' with 'SCHEMA' since schema-owning objects (tables, views, procedures) are addressed at the schema level, not the user level.
  • Updated example: EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Your description', @level0type = N'SCHEMA', @level0name = N'dbo';
  • If you are documenting a database-level principal (not schema), omit @level0type entirely, as database-level properties do not require this parameter.

Step 3: Validate Parameter Hierarchy for Nested Objects

  • If the property applies to a table or column, ensure the full hierarchy is present: @level0type = N'SCHEMA', @level1type = N'TABLE', @level2type = N'COLUMN' (if applicable).
  • Cross-check valid values against the Microsoft Learn documentation page for sp_addextendedproperty (Transact-SQL) specific to the 2025 release, as valid type strings can be version-dependent.

Step 4: Re-execute the Script

  • Run the corrected script via SSMS or sqlcmd on your Windows Server 2025 instance.
  • Confirm no further catalog exceptions are thrown in the Messages pane.

Alternative or Verification Steps

  • Verify the fix by querying the metadata directly: SELECT * FROM sys.extended_properties WHERE major_id = OBJECT_ID('dbo.YourTable'); to confirm the property was successfully registered.
  • If the error persists despite correct syntax, check for a corrupted or outdated sp_addextendedproperty system object by running sp_helptext 'sp_addextendedproperty' to ensure no custom overrides exist in the master database.

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

Troubleshooting Guide: Error 8197 – “The object ‘%.*ls’ does not exist or is invalid for this operation”

Why This Error Happens

This error typically occurs when SQL Server 2025 attempts to reference a database object (table, view, stored procedure, or index) that has been dropped, renamed, or has not yet been replicated/synchronized across a distributed query or replication topology. It is frequently triggered during replication processes when the schema on the subscriber does not match the publisher, or when metadata in the system catalog views becomes out of sync due to an interrupted DDL operation. In some cases, this is also caused by stale execution plans in the cache referencing an object that no longer exists in its original form.

Step-by-Step Resolution Guide

Step 1: Verify Object Existence and Schema Consistency

  • Open SQL Server Management Studio (SSMS) and connect to the instance reporting the error.
  • Run the following query to confirm the object exists: SELECT * FROM sys.objects WHERE name = 'YourObjectName';
  • Check if the object was recently dropped, renamed, or recreated under a different schema (e.g., dbo vs. a custom schema).

Step 2: Clear the Procedure Cache to Remove Stale Plans

  • Stale execution plans can reference old object IDs that no longer map correctly.
  • Run DBCC FREEPROCCACHE; to clear the entire instance-level cache (use with caution in production).
  • For a more targeted approach, use DBCC FLUSHPROCINDB(<database_id>); to clear the cache for a specific database only.

Step 3: Check and Repair Replication Metadata (If Applicable)

  • If the error occurs during a replication job, open the Replication Monitor in SSMS to identify the failing article.
  • Navigate to the Distribution Database and validate subscription status using sp_helpsubscription.
  • If schema mismatches are found, re-run the snapshot agent to resynchronize the subscriber: Right-click the Publication > Generate Snapshot.

Step 4: Run Database Consistency Checks

  • Corrupted system catalog pages can sometimes cause the engine to report objects as invalid.
  • Execute DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to scan for corruption.
  • Review the output for any allocation or consistency errors related to system tables (e.g., sysobjects, sysindexes).

Alternative or Verification Steps

  • Verification: Re-execute the specific query or stored procedure that triggered the error; if it completes without the 8197 error and returns expected row counts, the fix was successful.
  • Alternative: If the error persists only within SSMS Object Explorer, try refreshing the metadata cache manually via EXEC sp_refreshsqlmodule 'YourObjectName'; or restart the SSMS session to force a client-side cache reset.

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

Troubleshooting Guide: Error 8196 – Duplicate Column Specified as ROWGUIDCOL

Why This Error Happens

Error 8196 occurs when a CREATE TABLE or ALTER TABLE statement attempts to designate more than one column in the same table with the ROWGUIDCOL property. SQL Server 2025 enforces a strict rule that only a single column per table may carry this attribute, since ROWGUIDCOL is used to flag the column that uniquely identifies rows via a GUID for replication and merge scenarios. This typically happens due to copy-paste errors in T-SQL scripts, legacy migration scripts that redefine an existing ROWGUIDCOL column without dropping the property first, or schema merge conflicts when combining table definitions from multiple sources.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting Columns

  • Run the following query to inspect which columns currently have the ROWGUIDCOL property set on the affected table:
  • SELECT name, is_rowguidcol FROM sys.columns WHERE object_id = OBJECT_ID('YourSchema.YourTableName') AND is_rowguidcol = 1;
  • Note the column names returned — if more than one row appears, you have confirmed the source of Error 8196.

Step 2: Remove the ROWGUIDCOL Property from the Extra Column

  • Use ALTER TABLE to drop the ROWGUIDCOL designation from the duplicate or incorrect column rather than dropping the column itself.
  • Example syntax: ALTER TABLE YourSchema.YourTableName ALTER COLUMN DuplicateColumnName ADD ROWGUIDCOL is not valid for removal — instead, you must drop and recreate the column constraint using sp_help 'YourTableName' to review constraints, then recreate the column without the property.
  • If the column was defined inline in a CREATE TABLE script, manually edit the script in SQL Server Management Studio (SSMS) located under C:\Program Files (x86)\Microsoft SQL Server Management Studio 21\Common7\IDE\Ssms.exe and remove the extra ROWGUIDCOL keyword.

Step 3: Correct the Source Script or Migration File

  • Open the original .sql deployment script, typically found in your project repository or under C:\SQLScripts\Deployment\.
  • Search for all instances of the keyword ROWGUIDCOL using Ctrl+F in SSMS or VS Code.
  • Ensure only one column definition (commonly a uniqueidentifier column named RowGuid or GUIDColumn) includes the ROWGUIDCOL keyword, then save and re-run the script.

Step 4: Re-run the Table Creation or Alteration Statement

  • Execute the corrected script against the target database in SSMS or via sqlcmd:
  • sqlcmd -S YourServerName -d YourDatabaseName -i "C:\SQLScripts\Deployment\FixedScript.sql"
  • Confirm the script completes without raising Error 8196 in the Messages pane.

Alternative or Verification Steps

  • Verify the fix by re-running the diagnostic query from Step 1 — it should now return exactly one row with is_rowguidcol = 1, or zero rows if no ROWGUIDCOL column is required.
  • If the error persists after editing the script, drop the table entirely (if no production data exists) and recreate it from a clean, validated template to rule out hidden duplicate definitions in linked synonyms or views.

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

Troubleshooting Guide: Error 8193 – Cannot Execute a Procedure Marked FOR REPLICATION

Why This Error Happens

This error occurs because stored procedures marked with the FOR REPLICATION option are designed to be executed exclusively by replication agents, not by direct user calls, applications, or ad-hoc T-SQL scripts. SQL Server 2025 blocks manual execution of these procedures as a safeguard to prevent replication topology corruption or data inconsistency between the Publisher and Subscriber. This typically surfaces when a developer or application mistakenly calls a replication stored procedure directly, or when a replication agent’s security context lacks the proper execution rights.

Step-by-Step Resolution Guide

Step 1: Identify the Calling Context

  • Check whether the procedure is being called manually via SSMS, a custom application, or an external script.
  • Run the following query to confirm the procedure’s replication flag status:
  SELECT name, OBJECTPROPERTY(object_id, 'IsExecuted') AS IsExecuted,
         OBJECTPROPERTY(object_id, 'ExecIsForReplication') AS ForReplicationFlag
  FROM sys.objects
  WHERE name = 'YourProcedureName';
  • If ForReplicationFlag returns 1, the procedure is restricted to replication agents only.

Step 2: Correct the Execution Source

  • If the call is coming from an application or script, remove the direct call to the replication procedure; it should only be invoked by the Distribution Agent, Log Reader Agent, or Merge Agent.
  • Reroute any custom logic to call a standard, non-replication wrapper procedure instead.
  • If you intentionally need to re-run replication logic manually (e.g., for testing), use sp_MSrepl_startsynctran or equivalent replication-safe procedures rather than the raw FOR REPLICATION object.

Step 3: Validate Replication Agent Permissions

  • Open SQL Server Management Studio (SSMS) and navigate to Replication > Local Publications > [Your Publication] > Properties > Subscriptions.
  • Confirm the SQL Server Agent service account (found in Services.msc on Windows Server 2025) has db_owner or appropriate sysadmin rights on both the Publisher and Subscriber databases.
  • Restart the SQL Server Agent service to refresh the agent’s security token:
  net stop SQLSERVERAGENT
  net start SQLSERVERAGENT

Step 4: Rebuild the Replication Procedure (If Corrupted)

  • If the procedure metadata appears corrupted, drop and regenerate it using the Replication Wizard in SSMS under Local Publications > Reinitialize Subscriptions.
  • Alternatively, run sp_scriptpublicationcustomprocs to regenerate the FOR REPLICATION stored procedures from scratch at:
    C:\Program Files\Microsoft SQL Server\160\COM\

Alternative or Verification Steps

  • Verify the fix by monitoring the Replication Monitor (SSMS > Replication > Launch Replication Monitor) to confirm the Distribution Agent runs without throwing Error 8193 on the next sync cycle.
  • As a fallback, drop the subscription entirely and recreate it via the New Subscription Wizard, ensuring “Agent” is selected as the execution context rather than manual/user execution.

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

Troubleshooting Guide: SQL Server Error 8195 – “Cannot create on Insert”

Why This Error Happens

Error 8195 typically occurs when a linked server query attempts to create a table or object using distributed queries (via OPENQUERY or four-part naming) but lacks the proper permissions or schema mapping on the remote provider. This is common when the linked server login does not map to a user with db_ddladmin or sysadmin rights on the target database, or when the OLE DB provider does not support the specific INSERT...EXEC or SELECT INTO operation being requested. It can also surface due to a mismatch between the local and remote collation settings, causing the provider to reject the implicit schema creation.

Step-by-Step Resolution Guide

Step 1: Verify Linked Server Security Mapping

  • Open SSMS, navigate to Server Objects > Linked Servers > [YourLinkedServer] > Properties > Security.
  • Ensure “Be made using this security context” is set with a remote login that has write/DDL permissions.
  • Run EXEC sp_helplinkedsrvlogin; to confirm the current mapping configuration.

Step 2: Check OLE DB Provider Options

  • Right-click the Linked Server, go to Properties > Provider Options.
  • Enable “Allow InProcess” for the specific provider (e.g., MSOLEDBSQL) to prevent out-of-process restrictions that block DDL creation.
  • Enable “Dynamic Parameters” if the query involves parameterized inserts.

Step 3: Grant Explicit DDL Permissions

  • Connect directly to the target (remote) server instance.
  • Execute the following T-SQL to grant schema modification rights to the user:
  USE [TargetDatabase];
  GRANT CREATE TABLE TO [RemoteUser];
  ALTER ROLE db_ddladmin ADD MEMBER [RemoteUser];

Step 4: Align Collation Settings

  • Check for collation conflicts using SELECT SERVERPROPERTY('Collation'); on both source and destination servers.
  • If mismatched, explicitly cast the insert query using COLLATE DATABASE_DEFAULT in your INSERT statement to bypass the conflict.

Alternative or Verification Steps

  • Verification: Re-run the specific INSERT INTO ... SELECT or OPENQUERY statement that triggered the error; if successful, check the target table via sp_help 'TableName' to confirm structure integrity.
  • Alternative: If permissions cannot be altered on the remote server, bypass the direct insert by exporting data to a flat file (BCP) and importing it locally using BULK INSERT.

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

Troubleshooting Guide: Error 8192 – Replication Filter Procedures Cannot Have Parameters

Why This Error Happens

Error 8192 occurs when a stored procedure used as a replication filter in SQL Server 2025 is defined with one or more input parameters. SQL Server’s replication engine requires filter procedures to be parameterless because the replication agent cannot pass dynamic values to the procedure during the synchronization process. This restriction is enforced at the engine level, so any attempt to register a parameterized procedure as a filter will immediately fail validation.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Stored Procedure

  • Open SQL Server Management Studio (SSMS) and connect to the Publisher instance.
  • Navigate to the Replication node and locate the Publication that references the filter procedure.
  • Run the following query to inspect the procedure definition:
  EXEC sp_helptext 'dbo.YourFilterProcedureName';
  • Confirm whether the CREATE PROCEDURE statement includes any @parameter declarations.

Step 2: Rewrite the Procedure Without Parameters

  • Remove all parameter declarations from the procedure signature.
  • Replace any logic that relied on external parameter values with hard-coded values, system functions (like SUSER_SNAME()), or logic pulled directly from table data using HOST_NAME() or SYSTEM_USER.
  • Example of a corrected, parameterless filter procedure:
  ALTER PROCEDURE dbo.YourFilterProcedureName
  AS
  SELECT 1
  WHERE SUSER_SNAME() = 'SomeFixedValue';
  • Save and execute the script to update the procedure on the Publisher database.

Step 3: Re-link the Procedure to the Publication Filter

  • In SSMS, right-click the Publication and select Properties.
  • Go to the Filter Rows tab and remove the old filter reference if it is cached incorrectly.
  • Re-add the filter by selecting Add > Add Manually Coded Filter, pointing it to the newly updated parameterless procedure.
  • Click OK to save changes, then force the Snapshot Agent to regenerate:
  EXEC sp_startpublication_snapshot @publication = 'YourPublicationName';

Step 4: Restart Replication Agents

  • Open Replication Monitor and locate the associated Snapshot Agent and Log Reader Agent jobs.
  • Right-click each agent and select Stop, then Start to clear any cached execution plans referencing the old procedure signature.
  • Alternatively, restart the SQL Server Agent service via services.msc on the Windows Server 2025 host if agents remain unresponsive.

Alternative or Verification Steps

  • Verify the fix by checking the SQL Server Error Log (Management > SQL Server Logs in SSMS) to confirm Error 8192 no longer appears after the Snapshot Agent runs successfully.
  • If the error persists, drop the publication filter entirely and recreate the publication from scratch using the New Publication Wizard, ensuring the “Filter Rows” step only lists parameterless procedures before finalizing.

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

Why This Error Happens

Error 8190 occurs when SQL Server’s replication engine attempts to compile a filter stored procedure that references a published table, but the table definition cannot be resolved within the current execution or replication context. This typically happens because the article (table) referenced in the filter clause hasn’t been fully registered with replication metadata before the procedure compilation step runs, or the table exists in a different schema/database context than the one the replication agent is scoped to. Corrupted or out-of-sync distribution metadata following an upgrade to SQL Server 2025 can also trigger this, since schema-binding checks are now stricter in the updated query processor.

Step-by-Step Resolution Guide

Step 1: Verify the Table Exists and Is Properly Published

  • Open SSMS and connect to the Publisher instance.
  • Run sp_helparticle @publication = 'YourPubName', @article = 'YourTableName' to confirm the table is correctly registered as an article.
  • Check that the schema name (e.g., dbo.TableName) matches exactly what’s referenced in the filter procedure — case sensitivity and schema mismatches are common causes on Windows Server 2025 collations.

Step 2: Rebuild the Replication Filter Procedure Manually

  • Script out the existing filter stored procedure using sp_helptext 'FilterProcName'.
  • Drop the procedure with DROP PROCEDURE dbo.FilterProcName.
  • Recreate it explicitly referencing the fully qualified table name, e.g.:
  CREATE PROCEDURE dbo.FilterProcName
  AS
  SELECT * FROM dbo.YourTableName WHERE YourFilterColumn = SUSER_SNAME()
  • Ensure the table is created and committed in the same database context before this script runs.

Step 3: Refresh Replication Metadata

  • Navigate to the Replication folder in SSMS Object Explorer.
  • Right-click the Publication → Properties → Articles tab, and re-check/re-apply the article filter settings.
  • Run sp_repladdcolumn or sp_reinitsubscription if the subscriber schema is out of sync, forcing a metadata refresh.

Step 4: Validate SQL Server and OS-Level Permissions

  • Confirm the SQL Server Agent service account has db_owner or sufficient ALTER rights on the publication database.
  • On Windows Server 2025, check Local Security Policy (secpol.msc) to ensure the service account hasn’t been restricted by newer “Credential Guard” defaults that block cross-database token validation during replication compilation.

Alternative or Verification Steps

  • Verify the fix by running the Replication Monitor (replmonitor.exe or via SSMS) and confirming the Snapshot Agent and Log Reader Agent complete without throwing Error 8190 during the next scheduled sync.
  • As an alternative, drop and fully re-create the publication using the New Publication Wizard, ensuring the filter is defined only after all articles are added and validated — this avoids the compilation timing issue altogether.

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

Troubleshooting Guide: Error 8191 – “Replication Filter Procedures Can Only Contain SELECT”

Why This Error Happens

This error occurs when a replication filter stored procedure contains statements other than a single SELECT statement, such as INSERT, UPDATE, DELETE, DDL commands, or control-of-flow logic like IF/WHILE blocks. SQL Server 2025’s replication engine strictly validates filter procedures at the time they are associated with an article, rejecting any procedure body that deviates from pure data retrieval logic. This commonly happens when developers migrate business logic into filter procedures or accidentally include temporary table creation, variable declarations beyond parameter scope, or nested procedure calls within the filter definition.

Step-by-Step Resolution Guide

Step 1: Locate and Review the Offending Filter Procedure

  • Open SQL Server Management Studio (SSMS) and connect to the Publisher instance.
  • Navigate to Replication > Local Publications > [Your Publication] > Articles.
  • Right-click the article using a filter and select Properties to view the associated filter procedure name (typically prefixed with sp_MSfilterproc_).
  • Script out the procedure using EXEC sp_helptext 'dbo.YourFilterProcName'; in a new query window.

Step 2: Clean Up the Procedure Body

  • Remove any statements that are not part of a single SELECT clause (e.g., strip out DECLARE, SET, IF, WHILE, or secondary INSERT/UPDATE statements).
  • Ensure the procedure contains only one SELECT statement with a WHERE clause referencing the @ parameter(s) passed by the replication agent.
  • Example of a valid structure:
  CREATE PROCEDURE dbo.sp_MSfilterproc_SalesFilter
      @region_id int
  AS
      SELECT * FROM dbo.SalesData WHERE RegionID = @region_id
  • Save the corrected script to a .sql file located in C:\ReplicationScripts\ for version control.

Step 3: Drop and Recreate the Filter Association

  • In SSMS, right-click the Publication and select Properties > Articles.
  • Clear the existing filter clause tied to the broken procedure to unlink it from the Publisher.
  • Execute the cleaned-up script against the Publisher database to recreate the procedure object.
  • Re-apply the filter via the Filter Rows wizard, pointing to the newly validated procedure.

Step 4: Reinitialize the Subscription

  • Because the filter logic changed, the Subscriber’s schema snapshot is likely out of sync.
  • Right-click the Subscription in Replication Monitor and select Reinitialize.
  • Run a new snapshot via the Snapshot Agent to push the corrected schema and filter logic to all Subscribers.

Alternative or Verification Steps

  • Verify the Fix: Open Replication Monitor, check the Distributor to Subscriber History tab, and confirm the Snapshot Agent and Distribution Agent complete successfully without Error 8191 appearing in the Agent job history logs.
  • Alternative Fix: If the procedure must contain complex logic, refactor the logic into a standard User-Defined Function (UDF) called from within the SELECT statement itself, rather than using procedural T-SQL directly inside the filter stored procedure.

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

Troubleshooting Guide: SQL Server Error 8189 — “You do not have permission to run ‘%ls’.”

Why This Error Happens

This error occurs when a SQL Server login or user attempts to execute a stored procedure, function, or extended procedure without being granted the explicit EXECUTE permission on that object. It commonly surfaces after a security hardening pass, a role membership change, or when an object’s ownership chain is broken (the calling object and the called object are owned by different users). In some cases, it also appears when the login lacks permission on system procedures due to overly restrictive GRANT/DENY configurations applied at the database or server level.

Step-by-Step Resolution Guide

Step 1: Identify the Object and the Blocked Login

  • Open the SQL Server error log or Windows Event Viewer and locate Error 8189; note the exact procedure/function name referenced by %ls.
  • Run SELECT * FROM sys.database_principals WHERE name = 'YourLoginName'; in SQL Server Management Studio (SSMS) to confirm the login exists in the target database.
  • Check current permissions using:
  SELECT * FROM fn_my_permissions('dbo.YourProcedureName', 'OBJECT');

Step 2: Grant the Correct EXECUTE Permission

  • Connect to the affected database using SSMS or sqlcmd with an account that has db_owner or sysadmin rights.
  • Run the following command, replacing placeholders with your actual object and user names:
  USE YourDatabaseName;
  GRANT EXECUTE ON OBJECT::dbo.YourProcedureName TO [YourLoginName];
  • If multiple procedures are affected, consider creating a custom database role and assigning EXECUTE permissions at the role level instead of per-user:
  CREATE ROLE db_executor;
  GRANT EXECUTE TO db_executor;
  ALTER ROLE db_executor ADD MEMBER [YourLoginName];

Step 3: Verify Ownership Chaining and Schema Consistency

  • Confirm that the calling object and the target object share the same schema owner; broken ownership chains frequently trigger Error 8189 even after permissions are granted.
  • Run:
  SELECT OBJECTPROPERTYEX(OBJECT_ID('dbo.YourProcedureName'), 'OwnerId');
  • If ownership differs, either reassign the schema owner using ALTER AUTHORIZATION or implement a certificate-based signing solution for cross-schema execution.

Step 4: Check for Explicit DENY Statements

  • Explicit DENY permissions override GRANT, which is a common hidden cause of this error.
  • Run the following to check for conflicting DENY entries:
  SELECT * FROM sys.database_permissions 
  WHERE grantee_principal_id = USER_ID('YourLoginName') AND state = 'D';
  • Remove any conflicting DENY statements with REVOKE DENY ON OBJECT::dbo.YourProcedureName TO [YourLoginName];

Alternative or Verification Steps

  • Log in as the affected user (or impersonate using EXECUTE AS USER = 'YourLoginName') and manually run the procedure to confirm the error no longer appears.
  • If the issue persists, restart the SQL Server service via Windows Services (services.msc) on Windows Server 2025 to clear any cached permission tokens, then re-test the procedure execution.

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

Troubleshooting Guide: SQL Server Error 8187

Why This Error Happens

Error 8187 occurs when an application attempts to execute or reuse a prepared statement handle while a previous operation on that same handle has not yet completed or been properly closed. This typically results from client-side connection pooling issues, improperly managed ADO.NET/ODBC command objects, or concurrent threads sharing the same connection and command handle without synchronization. It can also surface after a corrupted client-side cursor cache or an abrupt network interruption that leaves a prepared statement in a “busy” state on the server.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Application and Connection

  • Capture the error state code in parentheses (error state: %d) — this maps to a specific internal SQL Server condition.
  • Use SQL Server Profiler or Extended Events to trace Error:Exception events filtered on Error = 8187.
  • Correlate the SPID (Session Process ID) shown in the trace with sys.dm_exec_sessions and sys.dm_exec_connections to identify the client machine and login.
  • Run the following query to inspect active requests tied to the session:
SELECT session_id, status, command, wait_type, last_request_start_time
FROM sys.dm_exec_requests
WHERE session_id = <SPID>;

Step 2: Review and Fix Client-Side Command Handling

  • Check the application code for reused SqlCommand or ODBC statement handles across multiple threads without proper locking.
  • Ensure every prepared command calls .Unprepare() (ADO.NET) or SQLFreeStmt (ODBC) before the handle is reused or the connection is returned to the pool.
  • If using connection pooling, verify Max Pool Size and Min Pool Size settings in the connection string are not forcing premature handle reuse under load.
  • For legacy apps, disable statement caching temporarily by setting Enlist=false;Pooling=false; in the connection string to confirm the root cause.

Step 3: Update Drivers and Apply Patches

  • Confirm the client driver (ODBC Driver 18+, OLE DB Driver, or .NET SqlClient) is updated to the latest version compatible with SQL Server 2025.
  • On Windows Server 2025 / Windows 11, open Settings > Windows Update and install all pending cumulative updates, as some networking stack fixes affect TDS packet handling.
  • Download the latest Microsoft ODBC Driver from the official Microsoft Learn download page and reinstall it via:
msiexec /i msodbcsql18.msi IACCEPTMSODBCSQLLICENSETERMS=YES /quiet
  • Restart the SQL Server service after driver updates:
Restart-Service -Name 'MSSQLSERVER'

Step 4: Clear Corrupted Prepared Statement Cache

  • Execute DBCC FREEPROCCACHE to clear the stored procedure and prepared statement cache (use cautiously in production, as it will cause temporary recompilation overhead).
DBCC FREEPROCCACHE;
  • Alternatively, target a specific plan handle instead of a full cache flush:
DBCC FREEPROCCACHE (plan_handle);
  • Restart the affected application pool or service to force fresh handle allocation.

Alternative or Verification Steps

  • Re-run the previously failing query/application workflow and confirm Error 8187 no longer appears in the SQL Server Error Log (EXEC sp_readerrorlog;) or Windows Event Viewer under Application Logs.
  • If the error persists, enable trace flag 7806 temporarily for enhanced diagnostic connection logging, and consider isolating the workload to a dedicated connection pool to rule out multi-threaded handle collisions.

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

Why This Error Happens

This error occurs because SQL Server enforces a strict one-to-one mapping between a CLR class (assembly type) and a SQL Server user-defined type (UDT). It triggers when a CREATE TYPE statement attempts to bind a second SQL type to a .NET class that has already been registered to an existing SQL type within the same assembly. This is common after a failed deployment script re-run, a duplicate assembly registration, or when developers rename a SQL type but forget to drop the original type bound to the underlying DLL class.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting Type Mapping

  • Open SQL Server Management Studio (SSMS) and connect to your Windows Server 2025 instance.
  • Run the following query to find existing UDTs tied to the assembly in question:
SELECT t.name AS TypeName, a.name AS AssemblyName, at.assembly_qualified_name
FROM sys.types t
JOIN sys.assembly_types at ON t.user_type_id = at.user_type_id
JOIN sys.assemblies a ON at.assembly_id = a.assembly_id
WHERE a.name = 'YourAssemblyName';
  • Note the TypeName that is already mapped to the conflicting class.

Step 2: Drop the Redundant SQL Type

  • Before dropping, check for dependencies (tables, columns, or parameters using the old type) via sys.columns and sys.parameters.
  • If the old type is obsolete or a duplicate, remove it:
DROP TYPE [dbo].[OldConflictingTypeName];
  • If the type is actively used by columns, you must first migrate the data to a new column/type or alter the dependent objects before dropping.

Step 3: Drop and Re-register the Assembly (If Necessary)

  • If the conflict persists due to a corrupted or partially updated assembly registration, remove the assembly entirely:
DROP ASSEMBLY YourAssemblyName;
  • Re-deploy the updated .dll file via CREATE ASSEMBLY FROM 'C:\Path\To\YourAssembly.dll' to ensure a clean, single-mapping state.
  • Re-run your original CREATE TYPE script immediately after the assembly registration completes.

Step 4: Audit Deployment Scripts for Duplicates

  • Check your .sql publish/deployment scripts (e.g., SSDT or DACPAC output) for duplicate CREATE TYPE statements referencing the same EXTERNAL NAME [Assembly].[Namespace.ClassName].
  • Consolidate or comment out the redundant creation statement to prevent future re-occurrence during automated deployments.

Alternative or Verification Steps

  • Verify the Fix: Re-run the CREATE TYPE statement. If successful, confirm the mapping is unique by re-executing the query from Step 1 and ensuring only one row is returned for that specific assembly_qualified_name.
  • Alternative Fix: If dropping the type is not feasible due to heavy production dependencies, rename the new CLR class in your Visual Studio project and rebuild the assembly so it does not collide with the existing registered SQL type.

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

Troubleshooting Guide: SQL Server Error 8186

Why This Error Happens

Error 8186 occurs when a system function that is designed to work exclusively with user or system tables—such as OBJECTPROPERTY, sp_tableoption, or certain metadata functions—is called against an incompatible object type, such as a view, synonym, table-valued function, or an internal/external table. This typically happens due to a mismatch in object type expectations within a query, a poorly written stored procedure, or an application layer (like an ORM or migration script) that incorrectly references system catalog views. It can also surface after an upgrade to SQL Server 2025 if deprecated metadata functions are used against newer object types, such as Graph tables or Ledger tables, which have different internal structures.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Object

  • Check the SQL Server Error Log or Extended Events session to capture the exact statement text triggering Error 8186.
  • Run the following to correlate the error with a session:
  SELECT * FROM sys.dm_exec_requests WHERE session_id = <SPID>;
  • Verify the object type of the target table using:
  SELECT type_desc FROM sys.objects WHERE object_id = OBJECT_ID('YourObjectName');

Step 2: Validate the Object Type Against the Function Requirements

  • Confirm if the target object is a View, Synonym, or External Table rather than a standard User/System table.
  • For functions like sp_tableoption, ensure the target is not a View:
  EXEC sp_tableoption 'dbo.YourTable', 'table lock on bulk load', 'TRUE';
  • If the object is a Synonym, resolve the synonym to its base object first using sys.synonyms before executing the function.

Step 3: Update Application Code or Migration Scripts

  • Locate the application code or SSIS/DTS package referencing the function (often found in C:\Program Files\Microsoft SQL Server\160\DTS\Packages).
  • Replace deprecated system functions with modern catalog views (e.g., replace OBJECTPROPERTY checks with sys.tables or sys.views joins) to future-proof the script for SQL Server 2025 compatibility.
  • Recompile the stored procedure after the edit:
  EXEC sp_recompile 'YourStoredProcedureName';

Step 4: Check for Ledger or Graph Table Conflicts

  • If running on SQL Server 2025, verify if the table is a System-Versioned Ledger table, as some legacy functions do not support the internal ledger verification tables.
  • Query sys.tables and check the is_ledger_view column to confirm:
  SELECT name, is_ledger_view FROM sys.tables WHERE name = 'YourObjectName';

Alternative or Verification Steps

  • Verification: Re-run the original query or application process that triggered Error 8186; monitor the SQL Server Activity Monitor to ensure the session completes without throwing the exception.
  • Alternative: If the function is being called via a third-party tool, check for a patch or Cumulative Update (CU) for that tool, as compatibility with SQL Server 2025’s updated engine components may require a vendor-specific hotfix.

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

Troubleshooting Guide: SQL Server Error 8184 — “Error in BinaryChecksum”

Why This Error Happens

Error 8184 occurs when the BINARY_CHECKSUM() or CHECKSUM() function is called on a table or row set where none of the columns are of a comparable data type. SQL Server excludes non-comparable types such as text, ntext, image, xml, cursor, and SQL CLR user-defined types (geography, geometry, hierarchyid) from checksum calculations, and if a query or trigger attempts to compute a checksum using only these columns (or a wildcard * on a table composed entirely of such types), the engine has nothing valid to hash. This is not a corruption or permissions issue — it is a schema/query design conflict between the function and incompatible column types.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Object

  • Check the SQL Server error log or the application stack trace to find the exact statement, stored procedure, or trigger calling BINARY_CHECKSUM or CHECKSUM.
  • Use SQL Server Management Studio (SSMS) 21 (compatible with SQL Server 2025) and run:
  SELECT OBJECT_NAME(object_id), definition 
  FROM sys.sql_modules 
  WHERE definition LIKE '%BINARY_CHECKSUM%' OR definition LIKE '%CHECKSUM%';
  • Note which table(s) and which trigger (often INSTEAD OF or AFTER UPDATE triggers used for change tracking) are involved.

Step 2: Inspect the Table Schema for Non-Comparable Columns

  • Run the following to list column data types for the table in question:
  SELECT COLUMN_NAME, DATA_TYPE 
  FROM INFORMATION_SCHEMA.COLUMNS 
  WHERE TABLE_NAME = 'YourTableName';
  • Flag any columns using text, ntext, image, xml, geography, geometry, hierarchyid, sql_variant (in some contexts), or CLR UDTs.
  • Confirm whether the query uses BINARY_CHECKSUM(*) (wildcard), which automatically pulls in all columns including unsupported types.

Step 3: Rewrite the Query to Explicitly Reference Comparable Columns

  • Replace BINARY_CHECKSUM(*) with an explicit column list excluding incompatible types, for example:
  SELECT BINARY_CHECKSUM(OrderID, CustomerID, OrderDate, Status) 
  FROM Orders;
  • If the excluded columns (e.g., xml or geography) must be included in change detection, use HASHBYTES('SHA2_256', CAST(column AS VARBINARY(MAX))) instead, since HASHBYTES supports a broader range of types.
  • Update any associated trigger or stored procedure definitions via ALTER TRIGGER / ALTER PROCEDURE to reflect the corrected column list.

Step 4: Modernize Legacy Change-Tracking Logic (If Applicable)

  • If the checksum is being used for row-change detection (a common legacy pattern), migrate to SQL Server’s built-in Change Tracking or Change Data Capture (CDC) features instead:
  ALTER DATABASE YourDB SET CHANGE_TRACKING = ON;
  ALTER TABLE Orders ENABLE CHANGE_TRACKING;
  • This removes dependency on manual checksum logic entirely and avoids future type-compatibility errors.

Step 5: Deploy and Test the Corrected Object

  • Deploy the updated trigger/procedure to the Windows Server 2025 instance via SSMS or sqlcmd.
  • Run a manual UPDATE or INSERT statement against the affected table to confirm the trigger/procedure executes without raising Error 8184.

Alternative or Verification Steps

  • Verify the fix by re-running the original failing transaction/trigger and checking sys.dm_exec_requests or the SQL error log for absence of Error 8184.
  • If BINARY_CHECKSUM must remain unchanged structurally, as an alternative use CHECKSUM(column1, column2, ...) with an explicit list (same comparable-type restriction applies) or switch entirely to HASHBYTES() for full type support including XML and large object columns.

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

Troubleshooting Guide: Error 8185 — “Error expanding ****: An incomparable column has been found in an underlying table or view”

Why This Error Happens

This error occurs when a SELECT * statement is executed against a view or table that contains a column with an incomparable data type, such as text, ntext, image, xml, or certain CLR user-defined types, especially when combined with a UNION, DISTINCT, or GROUP BY operation. SQL Server’s query optimizer cannot internally compare these column types during the expansion of the wildcard character, causing the engine to reject the operation. This is frequently triggered after a schema change, a linked server query, or a legacy database migrated into SQL Server 2025 that still contains deprecated large object (LOB) data types.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Column

  • Open SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your Windows Server 2025 instance.
  • Run sp_help 'YourViewOrTableName' to inspect the data types of every column.
  • Look specifically for text, ntext, image, sql_variant, xml, or CLR-based types, as these are the most common culprits.
  • Check the view definition using sp_helptext 'YourViewName' to see if it uses UNION, DISTINCT, GROUP BY, or ORDER BY alongside SELECT *.

Step 2: Replace the Wildcard with Explicit Column Names

  • Rewrite the query to avoid SELECT *; explicitly list every column name instead (e.g., SELECT ID, Name, Email FROM dbo.Customers).
  • If the view itself is the problem, modify the view definition using ALTER VIEW dbo.YourView AS SELECT col1, col2, col3 FROM dbo.SourceTable.
  • Save the script and execute it in a non-production environment first to confirm the error no longer appears.

Step 3: Convert or Isolate Incomparable Data Types

  • If a text, ntext, or image column is found, convert it to a modern type using ALTER TABLE dbo.YourTable ALTER COLUMN YourColumn VARCHAR(MAX) (or NVARCHAR(MAX) / VARBINARY(MAX) as appropriate).
  • For xml or CLR type columns that must remain, exclude them from any UNION, DISTINCT, or GROUP BY clause by selecting them in a separate, simple SELECT statement.
  • Re-run DBCC CHECKDB('YourDatabaseName') to rule out underlying corruption in the table structure that may be compounding the issue.

Step 4: Rebuild Dependent Views and Refresh Metadata

  • Run sp_refreshview 'YourViewName' on all views that reference the altered table to update cached metadata.
  • If multiple views are affected, use sp_refreshsqlmodule in a loop via PowerShell or a T-SQL cursor to batch-update them.
  • Restart the SQL Server service via services.msc on Windows Server 2025 if metadata caching issues persist after refreshing.

Alternative or Verification Steps

  • Re-execute the original query or application call that triggered Error 8185; if it returns results without the “incomparable column” message, the fix is confirmed.
  • As an alternative, if altering the schema is not immediately possible, wrap the problematic column in a CAST or CONVERT function (e.g., CAST(YourColumn AS NVARCHAR(MAX))) within the query to bypass the comparison restriction temporarily.

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

Troubleshooting Guide: SQL Server Error 8183

Why This Error Happens

This error occurs because SQL Server 2025 enforces strict rules on computed columns, allowing only UNIQUE or PRIMARY KEY constraints to be applied to them—other constraint types such as FOREIGN KEY, DEFAULT, or CHECK (in certain configurations) are rejected at the schema level. The root cause is typically a T-SQL script or migration tool attempting to apply an unsupported constraint type directly to a computed column definition. This commonly surfaces during database schema migrations, ORM-generated scripts (Entity Framework, Dapper), or legacy scripts ported from older SQL Server versions where constraint validation was less strict.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Column and Script

  • Open SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your SQL Server 2025 instance.
  • Run the following query to locate computed columns in the affected table:
  • SELECT name, definition FROM sys.computed_columns WHERE object_id = OBJECT_ID('YourTableName');
  • Review the failing CREATE TABLE or ALTER TABLE script in the error log (Event Viewer > Applications and Services Logs > MSSQLSERVER) to pinpoint the exact constraint causing Error 8183.

Step 2: Modify the Constraint Type

  • Edit the T-SQL script and remove any unsupported constraint (e.g., FOREIGN KEY or DEFAULT) applied directly to the computed column.
  • If a UNIQUE constraint is intended, rewrite the syntax as follows:
  • ALTER TABLE YourTableName ADD CONSTRAINT UQ_ComputedCol UNIQUE (YourComputedColumn);
  • If you need a FOREIGN KEY relationship, create a persisted computed column and reference it in a separate, non-computed shadow column instead.

Step 3: Use a Persisted Computed Column Workaround

  • Alter the computed column definition to include the PERSISTED keyword, which allows broader constraint compatibility in some edge cases:
  • ALTER TABLE YourTableName ADD YourComputedColumn AS (ColumnA + ColumnB) PERSISTED;
  • Re-run the original constraint script to confirm whether persisting the column resolves the compatibility issue (note: this only works for UNIQUE/PRIMARY KEY, not FOREIGN KEY or CHECK with subqueries).

Step 4: Validate Schema in a Test Environment

  • Deploy the corrected script to a staging instance of SQL Server 2025 running on Windows Server 2025 before applying to production.
  • Use sqlcmd -S YourServerName -i FixedScript.sql from an elevated PowerShell or Command Prompt to execute and capture any residual errors.

Alternative or Verification Steps

  • Verify the fix by querying sys.key_constraints and sys.foreign_keys to confirm only UNIQUE/PRIMARY KEY constraints exist on the computed column, and re-run the original failing script to ensure Error 8183 no longer appears.
  • As an alternative, if the constraint logic truly requires FOREIGN KEY or CHECK enforcement, move the computed logic into a regular (non-computed) column populated via a trigger or application-layer logic instead.

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

Troubleshooting Guide: SQL Server Error 8180 — “Statement(s) Could Not Be Prepared”

Why This Error Happens

Error 8180 typically occurs when SQL Server attempts to prepare a dynamic SQL statement that references an invalid object, column, or parameter that cannot be resolved at compile time. This is often caused by schema mismatches, incorrect metadata caching, or a referenced table/column being renamed, dropped, or altered after an application’s execution plan was cached. It can also surface due to permission issues on underlying objects referenced within dynamically constructed queries, or when a parameterized query receives a data type mismatch that SQL Server cannot implicitly resolve.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Failing Statement

  • Enable SQL Server Profiler or Extended Events to capture the exact T-SQL batch triggering Error 8180.
  • Check the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the accompanying error context (it usually lists a secondary error, such as 207 or 208, immediately above 8180).
  • Note the specific object name, column, or parameter referenced in the failing statement.

Step 2: Validate Schema and Object Metadata

  • Run sp_help 'YourTableName' in SQL Server Management Studio (SSMS) to confirm the table/column structure matches what the application expects.
  • Check for recent schema changes using:
  SELECT * FROM sys.objects WHERE modify_date > DATEADD(DAY, -7, GETDATE());
  • If a column was renamed or dropped, update the application’s stored procedure or dynamic SQL string to reference the correct object.

Step 3: Clear the Procedure Cache and Recompile

  • Execute the following to remove stale cached execution plans that may be referencing outdated metadata:
  DBCC FREEPROCCACHE;
  • For a more targeted approach, recompile only the affected stored procedure:
  EXEC sp_recompile 'YourStoredProcedureName';
  • Restart the SQL Server service via Services.msc on Windows Server 2025 if cache corruption persists after recompilation.

Step 4: Verify Permissions on Referenced Objects

  • Confirm the executing login has SELECT, INSERT, UPDATE, or EXECUTE permissions on all objects referenced in the dynamic SQL statement.
  • Use the following query to audit permissions:
  SELECT * FROM fn_my_permissions('YourTableName', 'OBJECT');
  • Grant missing permissions using GRANT SELECT ON YourTableName TO [YourUser]; as needed.

Step 5: Rebuild Parameterized Queries with Explicit Data Types

  • Review any sp_executesql calls in the application code to ensure parameter data types explicitly match the target column definitions.
  • Avoid implicit conversions by casting parameters, for example: CAST(@Param AS NVARCHAR(50)).
  • Test the corrected query manually in SSMS before redeploying to production.

Alternative or Verification Steps

  • Re-run the original failing transaction or application workflow and confirm Error 8180 no longer appears in the SQL Server Error Log or Windows Event Viewer (Application log).
  • If the issue persists, restore a recent database backup to a test instance on Windows 11 and compare schema versions using tablediff.exe to pinpoint silent structural drift between environments.

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

Troubleshooting Guide: SQL Server Error 8181 – Text for ‘%.*ls’ is Missing from System Catalog

Why This Error Happens

Error 8181 occurs when SQL Server attempts to retrieve the definition text (such as a stored procedure, view, or trigger body) from the syscomments or sys.sql_modules system catalog, but the corresponding entry is missing or corrupted. This typically happens due to database corruption affecting system tables, an interrupted transaction during object creation, or manual tampering with system catalog views. It can also surface after a failed replication or improper restore where metadata became desynchronized from the actual object definitions.

Step-by-Step Resolution Guide

Step 1: Identify the Affected Object

  • Run DBCC CHECKDB (YourDatabaseName) WITH NO_INFOMSGS, ALL_ERRORMSGS; to confirm whether corruption exists in the system catalog.
  • Note the exact object name or ID referenced in the error message (replace %.*ls with the real object name from your error log).
  • Check C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for additional context around the timestamp of the failure.

Step 2: Script Out and Drop the Corrupted Object

  • Attempt to generate a CREATE script for the object using SQL Server Management Studio (SSMS) before dropping it, if possible.
  • If scripting fails due to missing metadata, manually reconstruct the object definition from a recent backup or source control repository.
  • Execute DROP PROCEDURE/VIEW/TRIGGER [SchemaName].[ObjectName]; to remove the broken catalog entry.

Step 3: Re-create the Object

  • Use the reconstructed script to run CREATE PROCEDURE/VIEW/TRIGGER with the original object name and logic.
  • Ensure the object is created under the same schema and with matching permissions as the original.
  • Grant necessary permissions again using GRANT EXECUTE ON [ObjectName] TO [RoleOrUser]; since dropping resets prior grants.

Step 4: Restore from Backup (If Recreation Is Not Possible)

  • If no script or backup copy of the object definition exists, restore the database to a point-in-time backup taken before the corruption occurred.
  • Use RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDatabase.bak' WITH REPLACE, RECOVERY; on a side instance to extract the clean object definition.
  • Script the clean object from the restored copy and apply it to the production database.

Step 5: Run Full Consistency Check

  • Execute DBCC CHECKDB (YourDatabaseName) WITH DATA_PURITY, ALL_ERRORMSGS; to confirm no further catalog or page-level corruption remains.
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER in PowerShell to clear any cached execution plans referencing the old object.

Alternative or Verification Steps

  • Verify the fix by querying sys.sql_modules and sys.objects to confirm the object_id now has a matching, non-null definition column entry.
  • If the error persists across multiple objects, treat it as a sign of deeper database corruption — restore the entire database from the last known good backup rather than fixing objects individually.

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

Troubleshooting Guide: Error 8179 – “Could not find prepared statement with handle %d”

Why This Error Happens

This error occurs when a client application attempts to execute a previously prepared SQL statement using a handle that no longer exists on the SQL Server instance. This typically happens because the connection was dropped and silently re-established (via connection pooling) without re-preparing the statement, causing a mismatch between the client-cached handle and the server-side cache. It can also occur due to premature cursor/statement cleanup caused by aggressive connection timeout settings or a failover event in an Always On Availability Group that reset the session state.

Step-by-Step Resolution Guide

Step 1: Verify Connection Pooling and Statement Caching Behavior

  • Check if the client application (ODBC, JDBC, or OLE DB driver) has “Connection Reset” enabled, as this clears prepared statement handles without notifying the application layer.
  • For ODBC/JDBC drivers, inspect the connection string for parameters like disableStatementPooling or statementCacheSize and ensure they align with server-side expectations.
  • Review application logs to confirm if the error correlates with a connection pool recycle event rather than a continuous active session.

Step 2: Review Server-Side Memory Pressure and Plan Cache Eviction

  • Open SQL Server Management Studio (SSMS) and run the following query to check if memory pressure is causing the server to evict cached plans prematurely:
SELECT * FROM sys.dm_exec_cached_plans WHERE cacheobjtype = 'Compiled Plan';
  • Navigate to Windows Server 2025 Task Manager or Performance Monitor (PerfMon) and check the “SQL Server:Memory Manager” object for low “Target Server Memory” values compared to “Total Server Memory.”
  • If memory pressure is confirmed, increase the “Max Server Memory” setting via sp_configure 'max server memory' to prevent the plan cache from being flushed.

Step 3: Check for Always On Availability Group Failover Conflicts

  • If the SQL Server 2025 instance is part of an Always On Availability Group, verify the Windows Server Failover Clustering (WSFC) logs for recent failover events using Get-ClusterLog -Node $env:COMPUTERNAME -Destination C:\ClusterLogs.
  • Confirm that the application’s retry logic is configured to re-prepare statements immediately following a MultiSubnetFailover=True reconnection event in the connection string.
  • Update the application driver to the latest version (e.g., Microsoft ODBC Driver 18 for SQL Server) to ensure compatibility with session state handling during failovers.

Step 4: Disable Forced Parameterization or Adjust Prepare/Execute Model

  • Open the specific database properties in SSMS and check if “Parameterization” is set to “Forced” under Database Properties > Options.
  • If set to Forced, consider reverting to “Simple” to rule out parameterization conflicts causing handle mismatches:
ALTER DATABASE [YourDatabaseName] SET PARAMETERIZATION SIMPLE;
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER on Windows Server 2025 to clear any residual stale handles in memory.

Alternative or Verification Steps

  • To verify the fix, run a load test using SQLQueryStress or a custom script that simulates connection pooling resets while monitoring the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for recurrence of Event ID 8179.
  • As an alternative, if the error persists specifically after failovers, switch the client driver’s connection resiliency setting to “Idle Connection Resiliency” (available in newer SQL Server drivers) to allow the session to automatically re-prepare lost statements without throwing a fatal error.

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

Troubleshooting Guide: SQL Server Error 8178 – Parameterized Query Parameter Mismatch

Why This Error Happens

Error 8178 occurs when SQL Server’s auto-parameterization or sp_executesql process attempts to execute a query, but the data type, structure, or name of a declared parameter does not match what the engine expects at runtime. This is typically caused by application code passing mismatched ADO.NET/ODBC parameter types (e.g., passing a VARCHAR where NVARCHAR is expected), implicit conversion conflicts, or a corrupted/stale execution plan in the cache referencing an outdated schema. It can also surface after a schema change (like an altered column type) that invalidates existing cached query plans referencing the old parameter structure.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Query and Parameter Mismatch

  • Capture the full error text using SQL Server Profiler or Extended Events (xel trace) to see the exact parameterized query string and the specific parameter name causing the conflict.
  • Check the application’s data access layer (e.g., Entity Framework, ADO.NET) to verify the parameter type being sent (e.g., SqlDbType.NVarChar) matches the column definition in the database schema.
  • Run sp_helptext or check the stored procedure definition to compare expected vs. actual parameter data types.

Step 2: Clear the Procedure Cache to Remove Stale Plans

  • If a recent schema change (ALTER TABLE/ALTER PROC) caused the mismatch, flush the specific stale plan rather than guessing.
  • Run the following T-SQL to find the specific plan handle:
  SELECT plan_handle, text FROM sys.dm_exec_cached_plans 
  CROSS APPLY sys.dm_exec_sql_text(plan_handle) 
  WHERE text LIKE '%YourProcedureName%';
  • Remove the specific cached plan to force a recompile: DBCC FREEPROCCACHE(plan_handle);
  • Avoid running a global DBCC FREEPROCCACHE() on a production Windows Server 2025 instance during business hours, as it will cause a temporary performance hit while all queries recompile.

Step 3: Correct Application-Level Parameter Binding

  • Navigate to the application’s connection string or ORM mapping configuration (e.g., web.config, appsettings.json, or C# model attributes).
  • Explicitly define parameter sizes and types in the code to prevent SQL Server from guessing the parameter length (e.g., ensure [MaxLength(50)] attributes match the VARCHAR(50) column in SQL Server 2025).
  • If using sp_executesql manually, ensure the parameter definition string (N’@param1 INT’) strictly matches the variable type passed in the EXEC call.

Step 4: Update Statistics and Validate Schema Integrity

  • Run UPDATE STATISTICS on the affected table to ensure the query optimizer has accurate metadata regarding column types and distributions.
  • Verify there are no orphaned triggers or views that might be passing an outdated parameter structure to the underlying stored procedure.

Alternative or Verification Steps

  • Verification: Re-run the specific query or trigger the application action that caused the error. Monitor the SQL Server Error Log (via SSMS or Event Viewer under Applications and Services Logs > MSSQLSERVER) to confirm Error 8178 no longer appears.
  • Alternative: If the issue persists after cache clearing, rebuild the specific stored procedure using sp_recompile 'YourProcedureName' to force SQL Server to generate a completely fresh execution plan based on the current schema.

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

Troubleshooting Guide: SQL Server Error 8176 — “Resync procedure expects value of key”

Why This Error Happens

Error 8176 occurs when SQL Server’s cursor-based UPDATE or DELETE resync mechanism cannot match a row in the underlying base table because the key values have changed or no longer exist between the time the row was read and when it was modified. This is typically caused by a concurrent transaction modifying the same row, a missing or disabled unique index/primary key on the base table, or an application-level cursor that is referencing stale data. In SQL Server 2025 running on Windows Server 2025 or Windows 11, this can also surface due to corrupted statistics or an outdated cursor-driven ORM/data access layer that hasn’t been updated for new optimistic concurrency behaviors.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Procedure

  • Capture the full error text, which includes the specific key value causing the mismatch.
  • Use SQL Server Profiler or Extended Events (sys.dm_exec_requests + sys.dm_exec_sql_text) to trace the exact statement issuing the cursor UPDATE/DELETE.
  • Check the application or stored procedure code for FOR UPDATE cursors or WHERE CURRENT OF clauses.

Step 2: Verify Primary Key and Unique Index Integrity

  • Run the following to confirm a unique index exists on the base table:
  EXEC sp_helpindex 'YourTableName';
  • If missing, create a unique clustered or non-clustered index:
  CREATE UNIQUE INDEX IX_YourTable_Key ON dbo.YourTable(KeyColumn);
  • Rebuild any suspect indexes to rule out corruption:
  ALTER INDEX ALL ON dbo.YourTable REBUILD;

Step 3: Check for Concurrent Modifications

  • Review isolation levels being used by the application (READ COMMITTED, REPEATABLE READ, etc.).
  • Enable READ_COMMITTED_SNAPSHOT on the database to reduce row-versioning conflicts:
  ALTER DATABASE YourDatabase SET READ_COMMITTED_SNAPSHOT ON;
  • Audit triggers or external jobs (via SQL Server Agent or Windows Task Scheduler) that may be modifying the same rows simultaneously.

Step 4: Run Database Consistency Checks

  • Execute DBCC CHECKDB to rule out underlying corruption affecting key lookups:
  DBCC CHECKDB('YourDatabase') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for related I/O or page-level warnings.

Step 5: Update Drivers and Application Data Layer

  • Ensure the ODBC/OLE DB driver or ADO.NET provider connecting from Windows Server 2025 / Windows 11 is updated to the latest version compatible with SQL Server 2025.
  • Replace legacy server-side cursors with client-side cursors or set-based UPDATE statements where possible to avoid resync dependency entirely.

Alternative or Verification Steps

  • Re-run the original transaction/query after applying index fixes and confirm Error 8176 no longer appears in the Application Event Log or SQL Server Error Log.
  • If the issue persists, convert the cursor logic to a set-based MERGE or UPDATE...FROM statement, which eliminates the resync dependency altogether and is the recommended long-term fix.

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

Troubleshooting Guide: SQL Server Error 8177

Why This Error Happens

Error 8177 occurs when a T-SQL query includes a column in the SELECT list, HAVING clause, or ORDER BY clause that is neither wrapped in an aggregate function (such as SUM, COUNT, AVG, MAX, or MIN) nor explicitly listed in the GROUP BY clause. SQL Server’s query optimizer cannot determine a single deterministic value to return for that column across each grouped row set, so it rejects the query during the parsing/binding phase. This is a logical query-design issue rather than a server configuration or permissions problem, and it will occur consistently regardless of the Windows Server 2025 or Windows 11 host environment.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Column

  • Open the failing query in SQL Server Management Studio (SSMS) or Azure Data Studio and locate the exact column referenced in the error message (the %hs placeholder will be replaced with the actual column name at runtime).
  • Check whether this column appears in the SELECT, HAVING, or ORDER BY clause without being inside an aggregate function.

Step 2: Update the GROUP BY Clause

  • Add every non-aggregated column from your SELECT list into the GROUP BY clause.
  • Example fix:
  SELECT CustomerID, OrderDate, SUM(TotalAmount)
  FROM Sales
  GROUP BY CustomerID, OrderDate
  • Ensure column order and data types in GROUP BY match those referenced elsewhere in the query.

Step 3: Wrap Remaining Columns in Aggregate Functions

  • For any column that should not be part of the grouping logic (e.g., a descriptive field), wrap it in an aggregate function like MAX(), MIN(), or use STRING_AGG() for text concatenation.
  • Example: MAX(CustomerName) AS CustomerName instead of listing CustomerName directly.

Step 4: Use Window Functions as an Alternative

  • If you need row-level detail alongside aggregated values, replace GROUP BY logic with OVER (PARTITION BY ...) window functions, which allow non-aggregated columns without triggering Error 8177.
  • Example:
  SELECT CustomerID, OrderDate,
         SUM(TotalAmount) OVER (PARTITION BY CustomerID) AS TotalSpent
  FROM Sales

Step 5: Validate Query Execution Plan

  • Re-run the corrected query in SSMS and confirm no 8177 error is raised.
  • Review the execution plan (Ctrl+L) to ensure grouping operators are applied correctly and performance is acceptable.

Alternative or Verification Steps

  • Run the modified query against a small test dataset and confirm the output row count matches expected grouping logic (one row per unique combination of GROUP BY columns).
  • If the query is generated dynamically (e.g., via an ORM or reporting tool), inspect the generated SQL text in SQL Server Profiler or Extended Events to confirm the tool is not auto-generating an invalid GROUP BY clause.

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

Troubleshooting Guide: SQL Server Error 8175 – “Could Not Find Table %.*ls. Will Try to Resolve This Table Name Later.”

Why This Error Happens

This error occurs when SQL Server’s query optimizer attempts to resolve a table or object name during the binding phase but cannot locate it in the current context, often due to deferred name resolution for objects that do not yet exist or have been dropped mid-transaction. It frequently arises from stale execution plans in the procedure cache referencing renamed, moved, or deleted tables, or from schema mismatches where the object exists under a different schema than the one being queried. In some cases, it is triggered by corrupted metadata in system catalog views following an improper upgrade or migration to SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify the Table Actually Exists

  • Run SELECT * FROM sys.tables WHERE name = 'YourTableName'; in SSMS to confirm the object is present.
  • Check for schema prefix issues using SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES;
  • Confirm you are connected to the correct database context with SELECT DB_NAME();

Step 2: Clear the Procedure Cache and Recompile

  • Execute DBCC FREEPROCCACHE; to purge stale cached execution plans referencing the old table structure.
  • Follow with EXEC sp_recompile 'YourTableName'; to force SQL Server to rebuild the query plan.
  • If the error originates from a stored procedure, use ALTER PROCEDURE with a WITH RECOMPILE option temporarily to isolate the issue.

Step 3: Check for Deferred Name Resolution Conflicts

  • Inspect any dynamic SQL or sp_executesql calls where table names are constructed as strings, since these bypass early binding checks.
  • Validate that temporary tables (#TempTable) are created in the same session/scope before being referenced, as cross-scope references commonly trigger Error 8175.
  • Review linked server queries, as remote table resolution can lag if the linked server metadata cache is outdated; run EXEC sp_testlinkedserver 'YourLinkedServer'; to confirm connectivity.

Step 4: Repair System Catalog Corruption (If Migrated from Older Version)

  • Run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to detect catalog consistency errors introduced during upgrade to SQL Server 2025.
  • If corruption is found, restore from a known-good backup rather than using repair options that may cause data loss.
  • Update statistics post-restore using EXEC sp_updatestats; to ensure the optimizer has current metadata.

Step 5: Validate Windows Server 2025 / Windows 11 Service Account Permissions

  • Open Services.msc and confirm the SQL Server service account has read/write access to the database file path (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA).
  • Check Component Services > DCOM Config for any blocked permissions if the error surfaces during cross-instance queries.
  • Restart the SQL Server service via net stop MSSQLSERVER && net start MSSQLSERVER to clear any locked handles on system tables.

Alternative or Verification Steps

  • Re-run the original query or stored procedure after completing the steps above; the absence of Error 8175 in the SQL Server Error Log (viewable via EXEC sp_readerrorlog;) confirms resolution.
  • If the issue persists, restore the database to a pre-migration backup and re-apply schema changes incrementally while monitoring sys.dm_exec_query_stats for recurring plan cache anomalies.

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

Troubleshooting Guide: SQL Server Error 8173 – Incorrect Syntax for XML Data Type Method

Why This Error Happens

Error 8173 occurs when a Transact-SQL statement attempts to invoke an XML data type method (such as .value(), .query(), .nodes(), .exist(), or .modify()) using incorrect syntax, typically missing parentheses, incorrect parameter casting, or an improperly formatted XQuery expression. This commonly happens when parameter values passed to methods like .value() are not explicitly cast to a SQL data type, or when the XQuery/XPath expression string contains malformed syntax. It can also surface after upgrading to SQL Server 2025 if deprecated XML method calling conventions from older compatibility levels are still in use.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query and XML Method Call

  • Capture the exact query from the application log, SQL Server error log, or Extended Events session that triggered Error 8173.
  • Check Event Viewer under Applications and Services Logs > MSSQLSERVER on Windows Server 2025 for the full error text, including the method name referenced in %.*ls.
  • Run the query manually in SQL Server Management Studio (SSMS) connected to the instance to reproduce the error.

Step 2: Correct the XML Method Syntax

  • Ensure .value() is called with two parameters: an XQuery expression and a SQL data type, e.g., xmlColumn.value('(/Root/Element)[1]', 'NVARCHAR(100)').
  • Verify that .exist(), .query(), and .nodes() are called with a single string literal XQuery expression wrapped in single quotes.
  • Confirm that dynamic XPath values are not concatenated directly into the method call; use a variable and sql:variable() instead, e.g., xmlColumn.value('(/Root/Element)[1]', 'INT') should reference sql:variable("@var") for dynamic paths.
  • Remove any extra or mismatched parentheses around the method chain.

Step 3: Validate Database Compatibility Level

  • Open SSMS and right-click the database, then select Properties > Options.
  • Confirm the Compatibility Level is set to SQL Server 2025 (170) to ensure full support for current XML method syntax.
  • Run ALTER DATABASE [YourDB] SET COMPATIBILITY_LEVEL = 170; if an older level is detected and causing legacy parsing behavior.

Step 4: Rebuild Affected Stored Procedures or Functions

  • Locate any stored procedures, functions, or views referencing XML columns using sp_helptext [ObjectName].
  • Rewrite and redeploy the object using ALTER PROCEDURE or ALTER FUNCTION with corrected XML method syntax from Step 2.
  • Drop and recreate any cached execution plans using DBCC FREEPROCCACHE to eliminate stale plan references tied to the old syntax.

Step 5: Test in a Non-Production Environment

  • Deploy the corrected script to a staging instance running Windows Server 2025 first.
  • Execute the query under a test login with the same permissions as production to rule out permission-based parsing differences.
  • Confirm no other XML columns in the same batch trigger the same error before promoting to production.

Alternative or Verification Steps

  • Run the corrected query directly in SSMS and confirm it returns results without raising Error 8173; also check the SQL Server error log for recurrence after 24 hours of normal application traffic.
  • If the error persists, use SELECT TRY_CONVERT() wrapped around the XML method output to isolate whether the issue is a type mismatch rather than pure syntax, and consult the specific method’s documentation for SQL Server 2025 for any syntax changes introduced in this release.

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

Troubleshooting Guide: SQL Server Error 8174 – “Schema Lock With Handle %d Not Found”

Why This Error Happens

Error 8174 occurs when SQL Server’s internal lock manager attempts to release or reference a schema stability (Sch-S) or schema modification (Sch-M) lock that no longer exists in the lock table, typically due to a race condition during DDL operations on a table or index. This is frequently triggered by concurrent schema changes (such as online index rebuilds or ALTER TABLE operations) colliding with cached execution plans, or by corruption in the plan cache that references stale metadata handles. In rare cases, this can also surface due to a bug in specific SQL Server 2025 cumulative updates that mismanage lock handle cleanup during parallel query compilation.

Step-by-Step Resolution Guide

Step 1: Verify SQL Server Build and Apply Latest Cumulative Update

  • Open SQL Server Management Studio (SSMS) and run SELECT @@VERSION; to check your current build number.
  • Compare against the latest Cumulative Update (CU) for SQL Server 2025 on the Microsoft Update Catalog.
  • Download and install the latest CU, ensuring Windows Server 2025 / Windows 11 has no pending reboots at C:\Windows\WinSxS\pending.xml before applying.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.

Step 2: Clear the Plan Cache to Remove Stale Metadata References

  • Run DBCC FREEPROCCACHE; to purge the entire plan cache (use with caution in production during low-traffic windows).
  • Alternatively, target a specific database using ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; on SQL Server 2025.
  • Monitor Extended Events using the schema_lock_acquired and schema_lock_released events to confirm no residual handles remain.

Step 3: Identify and Isolate the Conflicting DDL Operation

  • Query active sessions during the error window using SELECT * FROM sys.dm_tran_locks WHERE resource_type = 'OBJECT';.
  • Check SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for correlating timestamps.
  • If an online index rebuild (ALTER INDEX ... REBUILD WITH (ONLINE = ON)) coincides with the error, reschedule it outside peak concurrent DDL activity.

Step 4: Rebuild Corrupted System Metadata (If Applicable)

  • Run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to rule out catalog corruption.
  • If corruption is found in system tables, restore from the last known good backup rather than using repair options, as schema lock corruption can indicate deeper catalog inconsistency.
  • Validate Windows Server 2025 storage subsystem health via Get-PhysicalDisk | Get-StorageReliabilityCounter in PowerShell to rule out underlying disk I/O errors causing metadata corruption.

Alternative or Verification Steps

  • After applying fixes, run a stress test using ostress.exe (from RML Utilities) to simulate concurrent DDL and DML operations, confirming Error 8174 no longer appears in the SQL Server Error Log.
  • If the issue persists after patching and cache clearing, open a Microsoft Support ticket with a memory dump captured via DBCC STACKDUMP at the moment of failure for deeper lock manager analysis.

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

Troubleshooting Guide: SQL Server Error 8172 — “The argument %d of the XML data type method must be a string literal”

Why This Error Happens

This error occurs because SQL Server’s XML data type methods (such as .exist(), .value(), .query(), or .nodes()) require their XQuery/XPath argument to be a compile-time constant string literal, not a variable, parameter, or dynamically constructed expression. SQL Server 2025 enforces this restriction because it needs to statically validate and optimize the XQuery expression at compile time, and it cannot do this if the argument is resolved at runtime. This typically happens when developers migrate dynamic SQL logic or pass a NVARCHAR variable directly into an XML method call instead of a hardcoded path string.

Step-by-Step Resolution Guide

Step 1: Identify the Offending XML Method Call

  • Review the query or stored procedure referenced in the error message and locate the .value(), .exist(), .query(), or .modify() call.
  • Check if the first argument (the XPath/XQuery expression) is being passed as a variable, e.g., @XPath, rather than a literal string like '(/Root/Element)[1]'.
  • Use SQL Server Management Studio (SSMS) 21 or Azure Data Studio to run the query in isolation to confirm which line triggers Error 8172.

Step 2: Replace Dynamic Variables with Static String Literals

  • Rewrite the query so the XPath expression is hardcoded directly into the method call.
  • Example of the problem: SELECT @xmlData.value(@xpathVar, 'VARCHAR(100)')
  • Example of the fix: SELECT @xmlData.value('(/Root/Element)[1]', 'VARCHAR(100)')
  • If the XPath genuinely needs to be dynamic, construct the entire SQL statement as a string and execute it via sp_executesql, embedding the literal XPath inside that dynamic string.

Step 3: Refactor Dynamic SQL Wrapping (If Applicable)

  • If the business logic requires variable node paths, build the full SELECT statement as a text string in a variable (e.g., @sql).
  • Embed the XPath value directly into the string using concatenation before execution.
  • Execute using EXEC sp_executesql @sql; so the XML method sees a literal at parse time, even though the outer wrapper is dynamic.
  • Validate there is no SQL injection risk by sanitizing any user-supplied path segments before concatenation.

Step 4: Check Compatibility Level and Database Collation Settings

  • Open SSMS, right-click the database, go to Properties > Options, and confirm the Compatibility Level is set to SQL Server 2025 (170).
  • Older compatibility levels carried over from upgraded databases (e.g., 2016 or 2019) can sometimes mask or alter how strictly literal-checking is enforced; resetting to the current level ensures consistent parser behavior.
  • Restart the SQL Server service via services.msc on Windows Server 2025 if you changed any server-level configurations.

Alternative or Verification Steps

  • Re-run the corrected query in SSMS and confirm Error 8172 no longer appears in the Messages tab; check the SQL Server error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for recurrence.
  • If dynamic XPath is unavoidable, consider restructuring the XML shredding logic using OPENXML or sys.dm_exec_describe_first_result_set as an alternative approach that doesn’t require compile-time literal validation.

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

Troubleshooting Guide: Error 8170 – Insufficient Result Space to Convert uniqueidentifier Value to char

Why This Error Happens

This error occurs when SQL Server attempts to implicitly or explicitly convert a uniqueidentifier value into a char or varchar data type whose defined length is too short to hold the full 36-character GUID representation. Since a standard uniqueidentifier string always requires 36 characters (32 hex digits plus 4 hyphens), any target column, variable, or parameter declared with fewer characters (such as char(30) or varchar(20)) will trigger this truncation error. This is typically caused by a schema definition mistake, a poorly cast query, or legacy table structures that were never updated to accommodate full GUID string lengths.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Object

  • Check the SQL Server error log or SSMS execution output to locate the exact query, stored procedure, or ETL job that triggered Error 8170.
  • Look specifically for CONVERT(), CAST(), or implicit conversions involving uniqueidentifier columns.
  • Use sp_helptext '<procedure_name>' to inspect stored procedure definitions for short char/varchar casts.

Step 2: Correct the Data Type Length in the Cast or Table Schema

  • Update any explicit conversion to use at least 36 characters:
  • SELECT CAST(YourGuidColumn AS varchar(36)) FROM YourTable;
  • If the issue originates from a table column definition, alter the column:
  • ALTER TABLE dbo.YourTable ALTER COLUMN GuidAsString varchar(36);
  • Avoid using char(32) or varchar(32), as this omits space for the four hyphens in the GUID format.

Step 3: Audit Linked ETL, SSIS, or Application Layer Mappings

  • Open SQL Server Integration Services (SSIS) packages or application connection strings that map uniqueidentifier fields to fixed-length string outputs.
  • Increase the output buffer or column length metadata in the SSIS Data Flow task to 36 characters or more.
  • Redeploy the package after adjustments via dtutil or SQL Server Management Studio.

Step 4: Recompile and Test Affected Stored Procedures

  • Force a recompilation of any modified stored procedures to clear cached execution plans:
  • EXEC sp_recompile 'dbo.YourStoredProcedure';
  • Run the procedure manually in SSMS with test data containing a full GUID value to confirm the conversion succeeds without truncation.

Alternative or Verification Steps

  • Run a validation query such as SELECT NEWID() AS TestGuid, CAST(NEWID() AS varchar(36)) AS ConvertedGuid; to confirm successful conversion without error.
  • If the error persists in third-party applications, check the application’s database schema documentation for any hard-coded short-length GUID fields and request a patch or configuration override from the vendor.

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

Troubleshooting Guide: SQL Server Error 8171 – Invalid Hint

Why This Error Happens

Error 8171 occurs when a query specifies a table, join, or query hint that SQL Server’s query optimizer does not recognize or cannot apply to the referenced object, typically due to a misspelled hint keyword, an unsupported hint for the object type (such as using a table hint on a view or table-valued function that doesn’t support it), or a syntax error in the WITH (...) or OPTION (...) clause. This can also surface after an upgrade to SQL Server 2025 if deprecated hints from older compatibility levels are still referenced in legacy stored procedures or ORM-generated queries. In some cases, corrupted or outdated cached execution plans combined with schema changes on the target object can trigger this error intermittently.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query and Hint

  • Capture the exact query text from the error message or SQL Server error log (Error: 8171, Severity: 16, State: 1).
  • Use Extended Events or SQL Profiler to trace which session and object triggered the error:
  SELECT * FROM sys.fn_xe_file_target_read_file('system_health*.xel', NULL, NULL, NULL)
  WHERE object_name = 'error_reported' AND error_number = 8171;
  • Note the object name and hint text referenced in the %ls and %.*ls placeholders.

Step 2: Validate Hint Syntax and Compatibility

  • Check the object type (table, view, synonym, or table-valued function) — some hints like NOLOCK or FORCESEEK are invalid on views or certain system objects.
  • Cross-reference the hint against the official supported list for your database compatibility level:
  SELECT compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • Remove or correct any deprecated hints (e.g., HOLDLOCK misuse, or legacy INDEX(0) syntax no longer supported in SQL Server 2025).

Step 3: Correct the Query and Clear Cached Plans

  • Edit the stored procedure, view, or application query to use a valid, supported hint syntax.
  • Clear any stale cached plans that may still reference the old hint:
  DBCC FREEPROCCACHE;
  • If using Windows Server 2025 Failover Clustering with SQL Server, ensure the corrected script is deployed consistently across all cluster nodes to avoid version mismatch.

Step 4: Update Compatibility Level if Needed

  • If the hint was valid in an older SQL Server version, verify whether raising or adjusting compatibility level resolves support:
  ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 170;
  • Re-test the query in a non-production environment before applying to production.

Alternative or Verification Steps

  • Re-run the corrected query directly in SQL Server Management Studio (SSMS) and confirm no Error 8171 appears in Messages or the SQL Server Error Log (%ProgramFiles%\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • If the error persists, strip all hints from the query temporarily to confirm the object itself is accessible, then reintroduce hints one at a time to isolate the invalid one.

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

Troubleshooting Guide: Error 8169 – Conversion Failed When Converting from a Character String to Uniqueidentifier

Why This Error Happens

This error occurs when SQL Server 2025 attempts to implicitly or explicitly cast a string value to the uniqueidentifier data type, but the string does not conform to the required GUID format (32 hexadecimal digits displayed in the pattern 8-4-4-4-12, optionally enclosed in braces). This is commonly caused by malformed data being passed from an application layer, leading or trailing whitespace, non-standard delimiters, or empty strings being inserted into a column or variable expecting a valid GUID. It can also surface when linked server queries or ETL pipelines (such as SSIS packages) pass mismatched data types without proper sanitation.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Data Source

  • Run the failing query in SQL Server Management Studio (SSMS) with a TRY_CAST wrapper to isolate the bad row without halting execution: SELECT TRY_CAST(YourColumn AS uniqueidentifier) FROM YourTable WHERE TRY_CAST(YourColumn AS uniqueidentifier) IS NULL AND YourColumn IS NOT NULL;
  • Check the Application Event Log in Windows Server 2025 (Event Viewer > Windows Logs > Application) for the specific query text associated with Event ID 8169 if verbose logging is enabled.

Step 2: Validate and Sanitize the String Format

  • Ensure the string strictly matches the pattern xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
  • Use LTRIM(RTRIM(YourColumn)) to remove hidden whitespace characters that often cause silent conversion failures.
  • If the data originates from a CSV import or an external API, verify the source isn’t appending Byte Order Mark (BOM) characters to the beginning of the string field.

Step 3: Correct the Table Schema or Query Logic

  • If the column is permanently storing GUIDs as text, consider altering the table to use the native uniqueidentifier type to enforce validation at the database engine level: ALTER TABLE YourTable ALTER COLUMN YourColumn uniqueidentifier;
  • For dynamic SQL or stored procedures, replace a direct CAST or CONVERT with TRY_CONVERT(uniqueidentifier, YourVariable) to handle null exceptions gracefully instead of throwing a hard error.

Step 4: Check Application Connection String Configurations

  • In Windows 11 or Windows Server 2025 environments, verify the ODBC Data Source Administrator (search odbcad32 in the Run dialog) settings if the application uses an ODBC driver.
  • Confirm the driver version (SQL Server Native Client or the Microsoft OLE DB Driver for SQL Server) matches the version recommended for SQL Server 2025 to prevent string encoding mismatches during data transmission.

Alternative or Verification Steps

  • To verify the fix, re-run the original transaction or stored procedure that triggered Error 8169; if using TRY_CAST, confirm the result set no longer returns NULL for rows that previously failed.
  • If the error persists despite clean data, use SQL Server Profiler (or Extended Events in SSMS) to trace the exact T-SQL statement being executed at the moment of failure to rule out a hidden trigger or linked server query manipulating the data.

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

Troubleshooting Guide: Error 8167 – UNPIVOT Column Type Conflict

Why This Error Happens

Error 8167 occurs when the columns specified in an UNPIVOT operation do not share a common or implicitly convertible data type. SQL Server requires all source columns being rotated into the value column to have identical (or safely compatible) data types, since UNPIVOT consolidates them into a single output column. This typically happens when a table includes a mix of types such as varchar, int, decimal, or datetime among the columns listed in the IN (...) clause of the UNPIVOT statement.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting Columns

  • Review the exact column names mentioned in the error message text (%.*ls will be replaced by the actual column name in the real error output).
  • Run sp_help 'YourTableName' or query INFORMATION_SCHEMA.COLUMNS to list the data type of every column included in your UNPIVOT IN (...) list.
  • Pay close attention to columns that look similar (e.g., Sales2023 int vs Sales2024 varchar(10)).

Step 2: Normalize Data Types Using CAST or CONVERT

  • Wrap mismatched columns in a CAST() or CONVERT() function inside a subquery or CTE before applying UNPIVOT.
  • Example fix:
  SELECT ID, Category, Value
  FROM (
      SELECT ID,
             CAST(Col1 AS decimal(18,2)) AS Col1,
             CAST(Col2 AS decimal(18,2)) AS Col2,
             CAST(Col3 AS decimal(18,2)) AS Col3
      FROM SourceTable
  ) AS SourceData
  UNPIVOT (
      Value FOR Category IN (Col1, Col2, Col3)
  ) AS UnpivotedTable;
  • Ensure the target data type chosen can losslessly hold the largest/most precise value from all source columns.

Step 3: Rebuild or Alter the Underlying Table Schema (If Applicable)

  • If the type mismatch stems from poor schema design (e.g., a table with inconsistent column types added over time), use ALTER TABLE ... ALTER COLUMN to standardize types permanently.
  • Example:
  ALTER TABLE SourceTable
  ALTER COLUMN Col2 decimal(18,2);
  • Back up the table first using SELECT * INTO SourceTable_Backup FROM SourceTable; in case the conversion causes data truncation or loss.

Step 4: Re-run the UNPIVOT Query

  • Execute the corrected query in SQL Server Management Studio (SSMS) connected to your SQL Server 2025 instance.
  • Confirm the query compiles and executes without raising Error 8167.

Alternative or Verification Steps

  • Verify the fix by running SELECT DISTINCT Category, SQL_VARIANT_PROPERTY(Value,'BaseType') FROM UnpivotedTable; to confirm all unpivoted values now share a consistent underlying type.
  • As an alternative, if columns must remain in their original mixed types, use UNION ALL with manual CAST() per column instead of UNPIVOT to achieve the same result with more explicit type control.

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

Why This Error Happens

SQL Server Error 8168 (“Cannot create worktable row because of excessive key size…”) occurs when a query operation—typically a sort, hash join, or GROUP BY—attempts to build an internal worktable in tempdb using a combined key size that exceeds the SQL Server engine’s internal row-size limit (usually around 8,060 bytes for older row formats, or exceeding the configured limit even with row/page compression). This is most often triggered by queries involving wide VARCHAR(MAX)/NVARCHAR(MAX) columns, many concatenated columns in an ORDER BY, GROUP BY, or DISTINCT clause, or implicit data type conversions that inflate the effective key width. It can also surface after a migration to SQL Server 2025 if legacy indexes or statistics were built under a different compatibility level that handled large object (LOB) key sizing differently.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query and Columns

  • Capture the exact T-SQL statement from the application or SQL Server error log (SQL Server Management Studio > Error Logs) that triggered Error 8168.
  • Check the ORDER BY, GROUP BY, DISTINCT, or JOIN clauses for wide columns (VARCHAR(MAX), NVARCHAR(MAX), XML, or multiple concatenated VARCHAR columns).
  • Use sys.dm_exec_query_stats combined with sys.dm_exec_sql_text to cross-reference recent failing query hashes.

Step 2: Reduce the Effective Key/Row Size

  • Rewrite the query to explicitly cast or truncate oversized columns, e.g., CAST(column AS VARCHAR(400)), before sorting or grouping.
  • Remove unnecessary columns from SELECT DISTINCT or GROUP BY lists—only include columns essential to the result set.
  • If the issue stems from an index definition, check it via:
  EXEC sp_helpindex 'YourTableName';

and rebuild any index whose combined key columns exceed 1,700 bytes (non-clustered) or 900 bytes (clustered) in SQL Server 2025.

Step 3: Adjust tempdb and Database Compatibility Settings

  • Confirm tempdb has sufficient space and multiple data files under C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\ (path may vary per instance name) to handle worktable spills.
  • Verify the database compatibility level is set correctly for SQL Server 2025 features:
  ALTER DATABASE YourDB SET COMPATIBILITY_LEVEL = 170;
  • Update statistics and rebuild indexes to ensure the optimizer selects an efficient plan that avoids unnecessarily wide worktables:
  UPDATE STATISTICS YourTable WITH FULLSCAN;
  ALTER INDEX ALL ON YourTable REBUILD;

Step 4: Apply Latest Cumulative Update

  • Open Windows Update or SQL Server Setup on Windows Server 2025 / Windows 11 and confirm the latest Cumulative Update (CU) for SQL Server 2025 is installed, as early releases have known worktable sizing bugs.
  • Restart the SQL Server service (services.msc → SQL Server (MSSQLSERVER) → Restart) after patching.

Alternative or Verification Steps

  • Re-run the original query in SSMS with SET STATISTICS IO, TIME ON to confirm no 8168 error appears and execution completes successfully.
  • If the error persists, isolate the query by removing one wide column at a time from the ORDER BY/GROUP BY clause to pinpoint the exact column causing the oversized worktable key, then apply targeted indexing or schema changes (e.g., splitting a wide column into a separate lookup table).