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

Troubleshooting Guide: Error 5594 in Microsoft SQL Server 2025

Why This Error Happens

Error 5594 occurs when a system function—typically HOST_NAME() or related T-SQL system functions that accept a computer_name_format parameter—receives an invalid or unsupported argument. This is usually caused by a mismatch between the SQL Server build version and the Database Compatibility Level, where newer format parameters (such as those introduced for FQDN resolution) are passed to an engine instance that doesn’t recognize them. It can also stem from corrupted system metadata or an outdated SQL Server Native Client/ODBC driver attempting to invoke the function with deprecated syntax.

Step-by-Step Resolution Guide

Step 1: Verify the SQL Server Build and Patch Level

  • Open SQL Server Management Studio (SSMS) and run SELECT @@VERSION; to confirm you are on a fully patched build of SQL Server 2025.
  • Check the Microsoft Release Notes to ensure Cumulative Update (CU) support for the computer_name_format parameter exists in your specific build.
  • Apply the latest CU via Windows Update or the standalone installer if the build is outdated.

Step 2: Correct the Function Syntax in the Query

  • Locate the query or stored procedure throwing the error (check Job History or the Error Log via EXEC sp_readerrorlog 0, 1, 'computer_name_format';).
  • Ensure the parameter value matches the exact accepted strings (e.g., 'short' or 'FQDN'), as values are case-sensitive and must be enclosed in single quotes.
  • Update the code: SELECT HOST_NAME('FQDN'); instead of using integer values or incorrect string literals.

Step 3: Reset Database Compatibility Level

  • Open a New Query window targeting the affected database.
  • Run ALTER DATABASE [YourDB] SET COMPATIBILITY_LEVEL = 170; (adjust level to match SQL Server 2025 standards).
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER to clear the query plan cache.

Step 4: Repair Corrupted System Function Metadata

  • Run DBCC CHECKDB('master') WITH NO_INFOMSGS, ALL_ERRORMSGS; to rule out corruption in system tables.
  • If corruption is found, restore the master database from a recent backup or rebuild system databases using the setup.exe /ACTION=REBUILDDATABASE command-line switch.

Alternative or Verification Steps

  • Verify: Re-run the original query or job step that failed; check the SQL Server Error Log (Management > SQL Server Logs in SSMS) to confirm Error 5594 no longer appears.
  • Alternative: If the error persists, bypass the native function by creating a CLR-based or PowerShell wrapper script to fetch the computer name via [System.Net.Dns]::GetHostName(), isolating the query from the native T-SQL bug.