Skip to content
Microsoft SQL Server

SQL Server Error 2628

String or binary data would be truncated in table (named column)

Applies to: 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.
Last technically reviewed 23 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
Msg 2628, Level 16, State 1, Line 1
String or binary data would be truncated in table 'Shop.dbo.Customers', column 'name'. Truncated value: 'Alexandra Constantin'.
Other forms of this message
Always followed by
The statement has been terminated.
Binary column (the value is shown empty)
Msg 2628, Level 16, State 1, Line 1
String or binary data would be truncated in table 'Shop.dbo.Files', column 'hash'. Truncated value: ''.
Older configuration (level 140 or lower, or VERBOSE_TRUNCATION_WARNINGS = OFF)
Msg 8152, Level 16, State 30, Line 1
String or binary data would be truncated.
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.
Last reviewed
23 October 2026

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';
What to look for

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;
What to look for

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 schema

If 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 data

If 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');
Result
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;
Result
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');
Result
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

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.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.