Troubleshooting Guide: SQL Server Error 9719
Why This Error Happens
Error 9719 occurs when Service Broker attempts to process a conversation endpoint, but the database associated with that conversation has been moved, detached, or restored since the conversation was originally established. This happens because the Service Broker route and dialog metadata (stored in sys.conversation_endpoints) becomes orphaned when the underlying database identity changes — typically after a restore, attach, or database mirroring/failover operation alters the database ID or Service Broker GUID. As a result, SQL Server cannot validate that the endpoint still belongs to an active, consistent database context, and it blocks further message processing on that conversation.
Step-by-Step Resolution Guide
Step 1: Verify the Service Broker GUID Consistency
- Run
SELECT name, service_broker_guid, is_broker_enabled FROM sys.databases WHERE name = 'YourDatabaseName';in SQL Server Management Studio (SSMS). - Compare this GUID against the GUID referenced in
sys.conversation_endpoints(farservice,service_idcolumns) to confirm a mismatch caused by the restore/attach operation. - Check the SQL Server error log (via
Get-ContentonC:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOGin PowerShell) for correlating timestamps of the restore/attach event.
Step 2: Re-enable and Reset Service Broker on the Database
- Open a new query window in SSMS and disable Service Broker temporarily:
ALTER DATABASE YourDatabaseName SET DISABLE_BROKER; - Re-enable it with a new broker identity:
ALTER DATABASE YourDatabaseName SET ENABLE_BROKER; - If the database was restored with
WITH KEEP_EXISTING, instead regenerate the GUID explicitly:ALTER DATABASE YourDatabaseName SET NEW_BROKER;(this clears all pending stale conversations safely).
Step 3: Clean Up Orphaned Conversation Endpoints
- Identify stale endpoints using:
SELECT conversation_handle, state_desc FROM sys.conversation_endpoints WHERE state_desc = 'DISCONNECTED_INBOUND' OR state_desc = 'DISCONNECTED_OUTBOUND'; - End the orphaned conversations manually:
END CONVERSATION 'conversation_handle_value' WITH CLEANUP; - Restart the SQL Server (MSSQLSERVER) service via
services.mscorRestart-Service -Name MSSQLSERVER -Forcein an elevated PowerShell session on Windows Server 2025 to clear any cached broker routing tables.
Step 4: Validate File and Permission Integrity Post-Restore
- Confirm the SQL Server service account has full read/write NTFS permissions on the
.mdf,.ldf, and.ndffiles under their storage path (commonlyD:\SQLData\orC:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\). - Run
DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;to rule out corruption introduced during the attach/restore process that could affect broker metadata.
Alternative or Verification Steps
- After applying fixes, send a test message through the application or run
SELECT * FROM sys.transmission_queue;— an empty or decreasing queue confirms conversations are processing normally again. - If the error persists, as a last resort, drop and recreate the affected Service Broker queues, services, and contracts using
CREATE QUEUE,CREATE SERVICE, andCREATE CONTRACTscripts matching your original schema, then re-test message flow.