I am importing some data from a temporary table which has a column defined as VARCHAR(150). The destination tables column is defined as NVARCHAR(200). I'm using an INSERT INTO statement, but when I run the SQL statement commenting out this column the query runs correctly. When I uncomment this line, I get:

Msg 8152, Level 16, State 4, Line 26

String or binary data would be truncated.

The statement has been terminated.

Any ideas as to why this is happening?

INSERT INTO table (col1, col2)
SELECT column1
  FROM tmpTable

col1 is defined as NVARCHAR(200) and col2 is a DateTime. column1 is defined as VARCHAR(150) and column2 is a DateTime.

When I comment out column1 and col1 the import statement runs fine.

  • 3
    Are you sure that the target table is at least as wide as the source table? What processing is happening? – gbn May 20 '13 at 10:59

Well this won't happen unless

  1. a trigger is firing on the target table, and the error happens there
  2. the INSERT does some processing that adds enough data to make it too wide

Also, what happens with this please? This can not fail unless there is some processing.

INSERT INTO table (col1, col2)
SELECT LEFT(column1, 200)
  FROM tmpTable
| improve this answer | |
  • There is a trigger, but this doesn't cause the error. Updated question with more detail. – Neil Knight May 20 '13 at 11:08
  • @NeilKnight: is your SQL that simple? and can you add the trigger code please – gbn May 20 '13 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.