1

I've just created a table and now I'm inserting data into that table. However, when I execute my Insert statement the error String or binary data would be truncated. occurs.

I've checked the data that would go into my varchar(100) columns and none of the data are longer than 20. I'm using 100 because I was debugging the issue myself but it's still not clearing up.

insert into dbo.tbl_Rooms
(room_id, building, Room_Layout, Capacity)
values  ('B002', 'Beech', null, null),
        ('E002', 'Elm', 'Classroom', null),
        ('E004', 'Elm', 'Classroom', null),
        ('E006', 'Elm', 'Classroom', null),
        ('E028', 'Elm', 'Physics Lab', null),
        ('E102', 'Elm', 'LRC', 72),
        ('E104', 'Elm', 'HE Room', null) 

The columns using varchar(100) are building and room_layout. Any ideas what's going wrong?

3
  • Can you please post your create table script, just to be sure? Commented Apr 5, 2014 at 20:19
  • 1
    @shree.pat18 I've found out the problem, I'm going to answer my own question Commented Apr 5, 2014 at 20:20
  • Good for you! Would be good if you could include some of the things you tried to check whilst investigating to make your answer a good resource for this error. Commented Apr 5, 2014 at 20:21

1 Answer 1

1

Right, I've found out the issue. Those columns were not the issue. It was the Room_ID column which I set, like an imbecile, to char(3) rather than char(4). Complete rookie mistake and I feel quite stupid at this very moment in time.

Guys, check your data types, or suffer the consequences as I have!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.