# SQLCODE -404: String too long for the column

Source: https://wndsoftware.com/mainframe-errors/sqlcode-404

### SQLCODE -404: String too long for the column

SQLCODE -404 (SQLSTATE 22001) means an INSERT, UPDATE, MERGE or other assignment tried to store a string longer than the target column allows, and the extra characters weren't just blanks. On current Db2 for z/OS releases the message doesn't name the column.


#### Other names for this code

Also written as `SQL -404`, `SQLCODE=-404`, `SQLCODE = -404`, `db2 -404`, `sqlstate 22001`, `SQL0404N`, `db2 string too long`, `SQL0404`, `db2 value too long for column`.


### What it means

When Db2 stores a character string in a CHAR or VARCHAR column, the string has to fit the column's length. Trailing blanks get special treatment. If the only characters that don't fit are blanks, Db2 drops them and the statement works. If any non-blank character would be lost, Db2 rejects the statement with -404 and changes nothing.

Db2 for z/OS uses a different code when the value comes straight from a host variable. That case is [-302](https://wndsoftware.com/mainframe-errors/sqlcode-302). You see -404 when the long string comes from inside the SQL, such as a literal, a concatenation, a function result or a column read by an INSERT ... SELECT. IBM's -404 topic also lists CALL parameters, SET and VALUES INTO targets, transition variables and index keys as targets that can be too short.

Lengths are in bytes. In a Unicode (UTF-8) table, many characters take two or three bytes, so a value can fit on the screen and still be too long for the column.

Older releases put the column name in the message. Db2 10 and later use a shorter text, "the SQL statement specifies a string that is too long", so you have to work out the column yourself.


### Common causes

- An INSERT ... SELECT copies data from a wider column into a narrower one, and some rows have more data than the target can hold.
- A concatenation or a function such as REPLACE builds a string longer than the column.
- A literal in the SQL is longer than the column, for example `SET STATUS = 'CANCELLED'` on a CHAR(8) column.
- Data converted into a UTF-8 table grew. Accented letters and symbols that take one byte in EBCDIC need two or more bytes in UTF-8.
- The table in one environment is defined with a shorter column than in another, so the same SQL works in test and fails in production.


### How to find the problem

- List the string columns the statement writes to and look up their lengths, for example `SELECT NAME, LENGTH, COLTYPE, CCSID FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = 'ORDERS' AND COLTYPE IN ('CHAR', 'VARCHAR')`. On older releases the message names the column.
- Run the source expression as a query and find the long values, for example `SELECT ORDER_NO, LENGTH(expr) FROM ... WHERE LENGTH(expr) > 40`.
- For Unicode data, compare LENGTH (bytes) with CHARACTER_LENGTH(expr, CODEUNITS32) (characters) to see whether multibyte characters are the problem.
- Compare the column definition across environments if the failure only happens in one of them.


### How to fix it

- If the data is right and the column is too short, make the column longer with `ALTER TABLE ... ALTER COLUMN ... SET DATA TYPE VARCHAR(n)`. Check what the change does to dependent views, packages and REORG status on your release first.
- If shortening is acceptable, cut the value on purpose with SUBSTR or LEFT. For UTF-8 data, cut by characters, not bytes, so you don't split a character.
- Check lengths in the program before the SQL runs and report the record instead of failing the whole job.
- Fix the column definition that differs between environments.


### IBM documentation

[IBM documentation: -404](https://www.ibm.com/docs/en/db2-for-zos/13.0.0?topic=codes-404). Use the documentation for your installed release.

[Report a correction to WND Software](https://wndsoftware.com/contact#message).

Technical reviewer: [Albert Joseph](https://wndsoftware.com/authors/albert-joseph), WND Software.

Last reviewed 2026-10-18 by the WND Software team. Written in our own words. For the full reference, check IBM’s Db2 for z/OS documentation for your release.


### Related codes

[SQLCODE -302 Input value invalid or too large Read →](https://wndsoftware.com/mainframe-errors/sqlcode-302)
[SQLCODE -433 Value too long Read →](https://wndsoftware.com/mainframe-errors/sqlcode-433)
[SQLCODE -406 Derived numeric value out of range Read →](https://wndsoftware.com/mainframe-errors/sqlcode-406)
[SQLCODE -407 Null value in a NOT NULL column Read →](https://wndsoftware.com/mainframe-errors/sqlcode-407)
[SQLCODE -408 Value not compatible with target type Read →](https://wndsoftware.com/mainframe-errors/sqlcode-408)

### Questions


#### What is the difference between -404 and -302?

On Db2 for z/OS, -302 means a host variable's value is too long or too big for its column. -404 means a string produced inside the SQL statement is too long.


#### Why didn't a value with extra trailing spaces fail?

Db2 drops trailing blanks when that makes the string fit. Only non-blank characters that won't fit cause -404.


#### Is it the same on Db2 for LUW and IBM i?

Yes. Db2 for LUW reports SQL0404N and IBM i reports SQL0404, both with SQLSTATE 22001.

[Db2 SQLCODEs](https://wndsoftware.com/mainframe-errors/db2-sqlcodes) · [SQLCODE -401](https://wndsoftware.com/mainframe-errors/sqlcode-401) · [SQLCODE -406](https://wndsoftware.com/mainframe-errors/sqlcode-406)

[← All error codes](https://wndsoftware.com/mainframe-errors/)
