Troubleshooting Guide: SQL Server Error 9776 – Service Broker GUID Mismatch
Why This Error Happens
This error occurs when the Service Broker GUID stored inside the database’s internal metadata (the service_broker_guid recorded at the page level) does not match the value registered for that database in the sys.databases system catalog. This mismatch typically happens after a database restore, attach operation, or database copy where the Service Broker identifier was not properly reconciled, or when a database was restored with WITH KEEP_EXISTING / improper NEW_BROKER options. It can also occur after replicating a database file manually (copy-paste of MDF/LDF) rather than using supported SQL Server migration methods.
Step-by-Step Resolution Guide
Step 1: Identify the Current Broker GUID Status
- Open SQL Server Management Studio (SSMS) connected to your Windows Server 2025 instance.
- Run the following query to inspect the current state:
SELECT name, service_broker_guid, is_broker_enabled
FROM sys.databases
WHERE name = 'YourDatabaseName';
- Note whether
is_broker_enabledis0and whether the GUID looks inconsistent with other environment records.
Step 2: Reset the Service Broker GUID Using ALTER DATABASE
- Take the database offline for single-user access to avoid conflicts:
ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
- Force a new Service Broker GUID to be generated and resynchronized with
sys.databases:
ALTER DATABASE YourDatabaseName SET NEW_BROKER;
- If you need to preserve existing conversations/dialogs instead of resetting them, use the error-recovery variant:
ALTER DATABASE YourDatabaseName SET ERROR_BROKER_CONVERSATIONS;
Step 3: Re-Enable Service Broker and Restore Multi-User Access
- Explicitly enable the broker now that the GUID is aligned:
ALTER DATABASE YourDatabaseName SET ENABLE_BROKER;
- Return the database to normal multi-user operation:
ALTER DATABASE YourDatabaseName SET MULTI_USER;
Step 4: Check File System and Permissions (Windows Server 2025 / Windows 11)
- Confirm the SQL Server service account has full read/write permissions on the
.mdfand.ldffiles located typically atC:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\. - Verify no leftover lock handles exist from antivirus or backup agents by checking Windows Resource Monitor (
resmon.exe) under the “CPU” tab’s associated handles search.
Alternative or Verification Steps
- Verify the Fix: Re-run the
SELECTquery from Step 1 and confirmis_broker_enablednow returns1and the GUID value is consistent acrosssys.databasesand internal metadata. - Alternative Solution: If
ALTER DATABASE SET NEW_BROKERfails due to active sessions, detach and re-attach the database usingsp_detach_dbandCREATE DATABASE ... FOR ATTACH WITH NEW_BROKERto force GUID regeneration at the attach level.