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
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 ... SELECTor import. - A column defined narrower than the data it receives in production.
How to fix it
-
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%';
-
Widen the column if the value is valid.
ALTER TABLE dbo.Customers ALTER COLUMN Email nvarchar(320) NOT NULL;
-
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
8152String or binary data truncated22001PostgreSQL: value too long for type1406MySQL: Data too long for columnORA-12899Oracle: value too large for column
More data conversion and truncation errors
245Conversion failed converting a value241Conversion failed for date and/or time242Out-of-range date conversion8115Arithmetic overflow error converting8114Error converting data type512Subquery returned more than 1 value8134Divide by zero error encountered220Arithmetic overflow error for data type
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.
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.