# SQL Server: Conversion failed when converting the varchar value 'x' to data type int. (Msg 245)

**Code:** `245` · **Category:** SQL · **Seen on:** SQL

SQL Server tried to convert text to a number (often implicitly) and hit a non-numeric value.

## 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

1. Compare like with like (quote the literal)
2. Use TRY_CONVERT/TRY_CAST to skip bad values
3. Concatenate with CONCAT()

## Detailed fix by platform

### SQL

1. `SELECT * FROM dbo.Items WHERE TRY_CONVERT(int, Code) = 42;`

## How to diagnose

1. **Value** — Which value fails?
2. **Expression** — Implicit conversion where?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/sql/mssql-conversion-failed-245)
