Troubleshooting Guide: Error 9712 – Invalid Service Contract Reference in Remote Service Binding
Why This Error Happens
Error 9712 occurs when a remote service binding in Service Broker points to a service contract ID that no longer exists or has been dropped from the database. This typically happens after an incomplete schema migration, a manually edited system catalog, or when a DROP CONTRACT statement is executed without first updating or removing dependent remote service bindings. In some cases, database restoration from an inconsistent backup or replication mismatch between msdb and the user database can also leave orphaned references in sys.remote_service_bindings.
Step-by-Step Resolution Guide
Step 1: Identify the Orphaned Remote Service Binding
- Open SQL Server Management Studio (SSMS) and connect to the affected SQL Server 2025 instance.
- Run the following query to locate the broken binding:
SELECT rsb.remote_service_binding_id, rsb.name, rsb.service_contract_id
FROM sys.remote_service_bindings rsb
LEFT JOIN sys.service_contracts sc
ON rsb.service_contract_id = sc.service_contract_id
WHERE sc.service_contract_id IS NULL;
- Note the
remote_service_binding_idandnamereturned, as these are required for the next step.
Step 2: Drop or Recreate the Invalid Binding
- Execute a controlled drop of the invalid binding using its name:
DROP REMOTE SERVICE BINDING [BindingNameFromStep1];
- If the binding is still required, recreate the missing service contract first:
CREATE CONTRACT [ContractName] ([MessageType] SENT BY INITIATOR);
- Then recreate the remote service binding referencing the valid contract ID:
CREATE REMOTE SERVICE BINDING [BindingName]
TO SERVICE 'ServiceName'
WITH USER = [UserName];
Step 3: Validate Service Broker Configuration Files
- On Windows Server 2025 / Windows 11, check the SQL Server error log located at:
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG - Look for additional Service Broker corruption messages (Error 9675 or 9676) that may indicate deeper catalog corruption.
- If corruption is suspected, run
DBCC CHECKCATALOG ('YourDatabaseName') WITH NO_INFOMSGS;to confirm system table consistency.
Step 4: Restart Service Broker on the Database
- Disable and re-enable Service Broker to force a clean reload of contract and binding metadata:
ALTER DATABASE [YourDatabaseName] SET DISABLE_BROKER;
ALTER DATABASE [YourDatabaseName] SET ENABLE_BROKER;
- Ensure no active transactions are using Service Broker queues before running this step to avoid blocking.
Alternative or Verification Steps
- Re-run the Step 1 query after applying fixes — if no rows are returned, the invalid binding reference has been resolved.
- If the error persists after recreating the binding, restore the
msdband user database from a known good backup taken before the schema change, then reapply only the valid Service Broker objects.