Troubleshooting Guide: SQL Server Error 2773 – Corrupted Collation ID (Invalid Sort Order ID)
Why This Error Happens
This error typically occurs when the master database’s system catalog contains a reference to a sort order ID that does not exist in the current build of sqlservr.exe, often due to a mismatch between the SQL Server binaries and the collation/locale data files. It can also result from a corrupted master.mdf/master.ldf file, an incomplete or interrupted upgrade from a previous SQL Server version, or manual tampering with system tables that store collation metadata. In rarer cases, this happens when a database is restored or attached from an instance using a legacy or custom sort order that Windows Server 2025 / Windows 11 builds of SQL Server 2025 no longer support.
Step-by-Step Resolution Guide
Step 1: Verify the SQL Server Instance Collation
- Open a new query window in SQL Server Management Studio (SSMS) and run:
SELECT SERVERPROPERTY('Collation');- Confirm the returned collation is a valid, supported Windows collation (e.g.,
SQL_Latin1_General_CP1_CI_AS) and not a legacy numeric sort order ID. - Cross-reference the result against
sys.fn_helpcollations()to ensure the collation is recognized by this build.
Step 2: Rebuild the Master Database with the Correct Collation
- Open an elevated Command Prompt on Windows Server 2025 / Windows 11.
- Navigate to the Setup bootstrap folder, typically:
C:\Program Files\Microsoft SQL Server\160\Setup Bootstrap\SQL2025\- Run the rebuild command, explicitly specifying a valid collation:
setup.exe /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS="BUILTIN\Administrators" /SAPWD="StrongPassword!123" /SQLCOLLATION=SQL_Latin1_General_CP1_CI_AS- This resets
master,model,msdb, andtempdbto a clean, compatible collation.
Step 3: Restore System Databases from a Known Good Backup (If Rebuild Fails)
- Stop the SQL Server service via
services.mscor: net stop MSSQLSERVER- Start the instance in single-user mode with the
-mflag usingsqlservr.exe -m -T3608from the Binn directory. - Restore
masterfrom the last known healthy backup: RESTORE DATABASE master FROM DISK = 'D:\Backups\master.bak' WITH REPLACE;- Restart the SQL Server service normally afterward.
Step 4: Check for Corrupted or Mismatched Collation Files
- Verify that
sqlservr.exeand its associated resource files (e.g.,Collation.dll, if applicable to your build) in the Binn folder match the installed SQL Server 2025 version. - Re-run SQL Server Setup in “Repair” mode from Control Panel > Programs and Features if any files appear mismatched or missing.
Alternative or Verification Steps
- After applying the fix, run
DBCC CHECKDB('master') WITH NO_INFOMSGS;to confirm there is no further corruption, and restart the SQL Server service to ensure Error 2773 no longer appears in the SQL Server Error Log (ERRORLOGfile in theLogfolder). - If the issue persists, consider performing a clean uninstall and reinstall of the SQL Server 2025 instance, ensuring you select a supported Windows collation during setup rather than relying on any legacy/custom sort order settings.