ColdFusion · Database exception

String Or Binary Data Would Be Truncated

What does String Or Binary Data Would Be Truncated mean in ColdFusion?

SQL Server rejects an INSERT/UPDATE because a value passed from cfquery is longer than the target column's defined size — a varchar(50) column fed a 60-character string, for instance. It's a data-length mismatch rather than a type mismatch, so it survives cfqueryparam type-checking and only fails once it reaches the database.

String Or Binary Data Would Be TruncatedAdobe ColdFusion · Lucee

Condition

SQL Server rejects an INSERT/UPDATE because a value passed from cfquery is longer than the target column's defined size — a varchar(50) column fed a 60-character string, for instance. It's a data-length mismatch rather than a type mismatch, so it survives cfqueryparam type-checking and only fails once it reaches the database.

Fix

Check the value length against the actual column definition before the write, or use cfqueryparam's maxlength attribute to fail fast in ColdFusion, and widen the column if truncation isn't acceptable rather than silently trimming input.

Pending source verification. Not yet checked against official documentation.

Related database exception