DBAtlas · Database operations atlas

8114: Error converting data type X to Y

SQL Server

What does it mean?

A value could not be converted from one data type to another because the types are incompatible. Unlike error 245, this is usually a failed type conversion at the parameter/expression level (e.g. varchar to numeric).

Why does it happen?

Sending non-numeric or malformed text to a numeric column/parameter; scale/precision overflow; trying to convert an empty string ('') to numeric; or passing an argument of the wrong type in a parameterized query. Common with implicit conversions generated by ORMs.

How to fix it

Verify that the converted values fit the target type. Use TRY_CONVERT / TRY_CAST for safe conversion; they return NULL on failure, so you can filter those rows with WHERE. Match parameter types to column types. Scan the data with ISNUMERIC/TRY_CAST to find offending rows, and clean up empty strings.

Open in DBAtlas →

More from this engine