SQL Server: Conversion failed when converting the varchar value 'x' to data type int. (Msg 245)
SQL Server tried to convert text to a number (often implicitly) and hit a non-numeric value.
Conversion failed when convertingConversion failed when converting date and/or time from character string Meaning
Comparing a varchar column with an int forces conversion of every row; one non-numeric value breaks the query. Data type precedence makes int win.
Common causes
- Comparing varchar columns with numbers
- Mixed data in a varchar column
- String concatenation with + and numbers
⚡ Quick fix
- Compare like with like (quote the literal)
- Use TRY_CONVERT/TRY_CAST to skip bad values
- Concatenate with CONCAT()
Detailed fix by platform
SQL
SELECT * FROM dbo.Items WHERE TRY_CONVERT(int, Code) = 42;
How to diagnose
- Value — Which value fails?
- Expression — Implicit conversion where?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in SQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026