My INSERT from a staging table fails with String or binary data would be truncated. The table has 60 columns, and the message does not say which one. How do I find it?
On SQL Server 2019 and later the message changed to error 2628 and includes the table name, column name and the value, so upgrading the compatibility level helps if you are on an older level.
On SQL Server 2016 SP2 and 2017 (CU12 and later) you can turn on trace flag 460, which gives the better message: DBCC TRACEON(460, -1); or at query level with OPTION (QUERYTRACEON 460).
Without those, compare lengths yourself. For each text column in the source run SELECT MAX(LEN(col)) and compare with the destination column's length in INFORMATION_SCHEMA.COLUMNS. A column that is 50 long in the destination but holds 70 in the source is your culprit. Widen the destination column or trim the data on purpose.
Found it, a notes column that was 100 and the source had 160. Widened it. Thanks.