SQL Server Error 8152 — String or binary data would be truncated

String or binary data would be truncated in table 'X', column 'Y'. Truncated value: '...'.

You tried to insert or update a value longer than the column's defined length (e.g. writing 60 characters into a varchar(50)). Modern SQL Server versions (2019+, under the newer compatibility level) name the exact table, column, and value — older versions just give the generic 8152 with no specifics.

Common causes

How to fix it

  1. If on SQL Server 2019+, check the database compatibility level (ALTER DATABASE ... SET COMPATIBILITY_LEVEL = 150 or higher) to get the detailed version of this error with the actual column and value named.
  2. Identify the offending column: SELECT name, max_length FROM sys.columns WHERE object_id = OBJECT_ID('table').
  3. Decide: widen the column (ALTER TABLE ... ALTER COLUMN ... varchar(100)) if the longer data is legitimate, or fix upstream validation if it's bad data.
  4. Add application-layer length validation so this fails fast and clearly, not deep in a batch job.

Paste your error and table definition here for a fix specific to your schema.

Try error explainer free →

Related