// SQL Server error reference

SQL Server error 2628: Truncated in table, column

A value is too long for its column. Unlike 8152, the message names the table, the column and the start of the value that would be cut off.

Error number
2628
Severity
16
Category
Data conversion and truncation
Error message
String or binary data would be truncated in table '%.*ls', column '%.*ls'. Truncated value: '%.*ls'.

What it means

Error 2628 is the detailed form of 8152, added in SQL Server 2019. It tells you exactly which column overflowed and shows the value (itself truncated in the message), so you can find the offending row. It is the default at database compatibility level 150 and later.

Common causes

  • A value longer than the column's declared length.
  • Columns mapped in the wrong order in an INSERT ... SELECT or import.
  • A column defined narrower than the data it receives in production.

How to fix it

  1. Use the column and value from the message to locate the source row.

    SELECT * FROM staging.Customers WHERE Email LIKE N'ada.lovelace.extremely.long%';
  2. Widen the column if the value is valid.

    ALTER TABLE dbo.Customers ALTER COLUMN Email nvarchar(320) NOT NULL;
  3. Or trim deliberately with LEFT() where cutting is acceptable.

Reproduce it safely

CREATE TABLE #t (code varchar(3));
INSERT INTO #t VALUES ('ABCD');
-- Msg 2628: String or binary data would be truncated in table 'tempdb.dbo.#t...', column 'code'. Truncated value: 'ABC'.
DROP TABLE #t;

Related errors

More data conversion and truncation errors

The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.

// fewer errors, faster fixes

Work on SQL Server in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.