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_statscross-applied withsys.dm_exec_sql_textto pinpoint the query handle associated with Error 5373. - Check if the error correlates with spatial functions (
geography::STUnion) orCONCAT_WS/IIFcalls with mixedtinyint,smallint, orintparameters.
Step 2: Correct Parameter Data Types Explicitly
- Modify the query to explicitly
CASTorCONVERTall parameters to a single matching type, prioritizingtinyintif 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.TinyIntandSqlDbType.Intin ADO.NET parameter collections). - Restart the SQL Server (MSSQLSERVER) service via
services.mscafter driver updates to clear cached execution plans.
Step 4: Clear and Rebuild Execution Plan Cache
- Run
DBCC FREEPROCCACHEto eliminate any corrupted or outdated cached plans that may be enforcing incorrect type assumptions from before a schema change. - Follow with
UPDATE STATISTICSon 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.