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

Troubleshooting Guide: SQL Server Error 5373 – “All Input Parameters Should Be of the Same Type”

Why This Error Happens

Error 5373 occurs when a system or user-defined function (commonly spatial functions, CONCAT_WS, or table-valued parameters) receives mixed data types across arguments where SQL Server expects uniform typing. This frequently stems from implicit conversions failing silently during schema upgrades, or from client applications (ODBC/OLE DB drivers) passing mismatched parameter types in a batch. In SQL Server 2025, stricter type-checking in the query optimizer surfaces this issue more aggressively than in prior versions, especially after in-place upgrades from SQL Server 2019/2022.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Procedure

  • Capture the exact T-SQL statement using Extended Events or the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • Run SELECT * FROM sys.dm_exec_query_stats cross-applied with sys.dm_exec_sql_text to pinpoint the query handle associated with Error 5373.
  • Check if the error correlates with spatial functions (geography::STUnion) or CONCAT_WS/IIF calls with mixed tinyint, smallint, or int parameters.

Step 2: Correct Parameter Data Types Explicitly

  • Modify the query to explicitly CAST or CONVERT all parameters to a single matching type, prioritizing tinyint if that is the base type referenced in the error.
  • Example fix: SELECT dbo.MyFunction(CAST(@Param1 AS tinyint), CAST(@Param2 AS tinyint)).
  • Update any stored procedures or views in SSMS (Object Explorer → Programmability → Stored Procedures) that pass variables without explicit casting.

Step 3: Update Client Drivers and Connection Strings

  • Ensure the application server (Windows Server 2025) is using the latest Microsoft OLE DB Driver 19 or ODBC Driver 18 for SQL Server, downloadable via winget install Microsoft.ODBCDriverforSQLServer.
  • Verify connection string parameters aren’t auto-converting types inconsistently (e.g., mixing SqlDbType.TinyInt and SqlDbType.Int in ADO.NET parameter collections).
  • Restart the SQL Server (MSSQLSERVER) service via services.msc after driver updates to clear cached execution plans.

Step 4: Clear and Rebuild Execution Plan Cache

  • Run DBCC FREEPROCCACHE to eliminate any corrupted or outdated cached plans that may be enforcing incorrect type assumptions from before a schema change.
  • Follow with UPDATE STATISTICS on the affected tables to ensure the optimizer has current type/cardinality metadata.

Alternative or Verification Steps

  • Re-run the original query or application transaction that triggered Error 5373 and confirm it completes without the type-mismatch exception in the Windows Event Viewer (Application Log, Source: MSSQLSERVER).
  • If the error persists, isolate the issue by testing the function/procedure directly in SSMS with hardcoded literal values of a single explicit type to confirm whether the root cause is client-side parameter binding rather than the database schema itself.