- Error number
- 2628
- Severity
- 16 (user-correctable error)
- State
- 1
- Product
- Microsoft SQL Server Database Engine
- Versions
- SQL Server 2019 to 2025 at database compatibility level 150 or higher, Azure SQL Database, Azure SQL Managed Instance. Microsoft documents trace flag 460 to enable it on SQL Server 2016 SP2 CU6 and 2017 CU12 and later builds.
- Category
- Data Type & Conversion
- Last reviewed
- 23 October 2026
On this page
What it means
Error 2628 means an INSERT or UPDATE tried to store a value longer than the named column allows; the message tells you the database, table, column and the start of the value.
Read the message in three parts: the table as database.schema.table, the column that is too narrow, and the truncated value. The value shown is already cut to the column width, not what you sent: inserting Alexandra Constantinople (24 characters) into VARCHAR(20) reports Alexandra Constantin. Search your source data for values that start with it. For binary columns the value is shown empty.
2628 is the detailed replacement for error 8152. SQL Server 2025 raises it when the database is at compatibility level 150 or higher and the scoped configuration VERBOSE_TRUNCATION_WARNINGS is ON, which is the default. The statement is rolled back either way; only the message differs.
Common causes
- Input or imported data longer than the column, for example a full name in VARCHAR(20).
- An UPDATE that replaces or appends text so the new value exceeds the column width.
- INSERT ... SELECT from a wider source column (for example NVARCHAR(MAX) staging into NVARCHAR(100)).
- A column sized for typical values rather than the longest legitimate one.
Diagnose it
Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.
Read the width of the named column
max_length is in bytes: divide by 2 for nchar and nvarchar. -1 means MAX.
SELECT c.name AS column_name, TYPE_NAME(c.user_type_id) AS data_type, c.max_length, c.is_nullable
FROM sys.columns AS c
WHERE c.object_id = OBJECT_ID(N'dbo.Customers')
AND c.name = N'name'; The current limit you are hitting, and the nullability to restate if you widen it.
Find every source value that is too long
SELECT id, name, LEN(name) AS len
FROM staging.Customers
WHERE LEN(name) > 20
ORDER BY len DESC; The message shows only the first failing value; this lists all of them, so one fix covers the whole load.
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Widen the named column
Changes schemaIf the longer value is legitimate, enlarge the column the message names, restating its nullability.
Caution:
Columns used in indexes or constraints may need those dropped and recreated, and on large tables the change can take locks. Test first.
ALTER TABLE dbo.Customers
ALTER COLUMN name VARCHAR(100) NULL;
Validate or shorten the value before writing
Changes dataIf the column width is right, reject the value in the application, or cut it deliberately with LEFT when losing the tail is acceptable.
INSERT INTO dbo.Customers (id, name)
VALUES (1, LEFT('Alexandra Constantinople', 20));
Examples
Inserting a value that is too long for a named column
CREATE TABLE dbo.Customers (
id INT PRIMARY KEY,
name VARCHAR(20)
);
-- 'Alexandra Constantinople' is 24 characters, the column holds 20
INSERT INTO dbo.Customers (id, name)
VALUES (1, 'Alexandra Constantinople');
Msg 2628, Level 16, State 1, Line 7 String or binary data would be truncated in table 'Shop.dbo.Customers', column 'name'. Truncated value: 'Alexandra Constantin'. The statement has been terminated.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
An UPDATE that overflows the column
CREATE TABLE dbo.Customers (
id INT PRIMARY KEY,
name VARCHAR(20)
);
INSERT INTO dbo.Customers (id, name) VALUES (1, 'Alexandra');
-- The name column is VARCHAR(20); the new value is longer
UPDATE dbo.Customers
SET name = 'Alexandra Constantinople'
WHERE id = 1;
Msg 2628, Level 16, State 1, Line 8 String or binary data would be truncated in table 'Shop.dbo.Customers', column 'name'. Truncated value: 'Alexandra Constantin'. The statement has been terminated.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
The same write on an older configuration raises 8152
Under compatibility level 140 or lower, or with the database scoped configuration VERBOSE_TRUNCATION_WARNINGS set to OFF, SQL Server raises the older error 8152 without naming the column. Reproduced on SQL Server 2025.
ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 140;
GO
CREATE TABLE dbo.Customers (
id INT PRIMARY KEY,
name VARCHAR(20)
);
INSERT INTO dbo.Customers (id, name)
VALUES (1, 'Alexandra Constantinople');
Msg 8152, Level 16, State 30, Line 7 String or binary data would be truncated. The statement has been terminated.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
How to prevent it
Size each string column for the longest legitimate value, enforce the same limit in forms and APIs, and check staging data with LEN before loading. For choosing widths and Unicode types, see SQL data types explained.
Keep databases at compatibility level 150 or higher with VERBOSE_TRUNCATION_WARNINGS ON so truncation always reports this detailed message rather than the bare 8152.
Common questions
Why is the truncated value in the message shorter than what I inserted?
SQL Server shows the value cut to the column width. Inserting a 24-character name into VARCHAR(20) reports the first 20 characters. Search the source for values starting with that text.
Why do I see 8152 instead of 2628?
The database is at compatibility level 140 or lower, or VERBOSE_TRUNCATION_WARNINGS is OFF. Both are per database: check sys.databases and sys.database_scoped_configurations for the database you write to.
Does the Truncated value show the whole row?
No. It shows one value, for the first column that would be truncated. Fix that column and rerun; another column may then report its own 2628.
Learn more on CodeWithSQL
Official documentation
- ALTER DATABASE SCOPED CONFIGURATION: VERBOSE_TRUNCATION_WARNINGS
- ALTER DATABASE compatibility level (Transact-SQL)
- Database Engine events and errors 2000 to 2999
Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.