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

Why This Error Happens

Error 13041 is thrown by the SQL Server Service Broker engine when a DDL statement (such as CREATE ROUTE, CREATE SERVICE, or CREATE MESSAGE TYPE) contains an attribute value — typically an address, service name, or contract identifier — that does not conform to the rules for a valid SQL identifier or URI format. This is most commonly caused by invisible Unicode characters, trailing whitespace, or illegal symbols (such as unescaped ampersands or slashes) copied into a script from an external source like a web page or email. It can also occur after an in-place upgrade to SQL Server 2025 if legacy Broker objects were created under a more permissive collation setting that the new engine now validates more strictly.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Object or Script

  • Open SQL Server Management Studio (SSMS) and locate the exact T-SQL batch that triggered the error in the Messages tab.
  • Run the following query to scan existing Broker objects for malformed names:
  SELECT name FROM sys.service_broker_services WHERE name LIKE '%[^a-zA-Z0-9_./:-]%';
  • Check the Windows Event Viewer under Applications and Services Logs > Microsoft > SQL Server > Admin for the full stack trace tied to Event ID 13041.

Step 2: Sanitize the Character String

  • Retype the identifier or address manually in Notepad (not a rich text editor) to strip hidden formatting characters.
  • Ensure the string does not exceed 128 characters and does not start with a number or reserved symbol.
  • If the value is a URI (common in CREATE ROUTE statements), verify it follows the exact pattern: TCP://hostname:port.

Step 3: Rebuild the Service Broker Object

  • Drop the corrupted object using DROP SERVICE [name]; or the equivalent command for your object type.
  • Recreate the object using the sanitized string from Step 2:
  CREATE SERVICE [CleanServiceName] ON QUEUE [dbo].[TargetQueue] ([ContractName]);
  • Restart the SQL Server Service Broker task via ALTER DATABASE [YourDB] SET ENABLE_BROKER; if the broker was disabled during troubleshooting.

Step 4: Validate Server Collation Compatibility

  • Confirm the database collation matches what Service Broker expects by running:
  SELECT DATABASEPROPERTYEX('YourDB', 'Collation');
  • If using Windows Server 2025 with a non-default regional locale, ensure the SQL Server instance collation was set to SQL_Latin1_General_CP1_CI_AS or your organization’s standard during installation.

Alternative or Verification Steps

  • Verify the fix by querying sys.transmission_queue and sys.service_broker_services to confirm the new object appears without errors and messages are flowing.
  • If the error persists, run DBCC CHECKDB on the affected database to rule out underlying page-level corruption that may be returning malformed string data to the Broker engine.