0

When executing the line of code below in sql server, I receive the error message:

String or binary data would be truncated.

What is the cause of this?

Line of code:

INSERT INTO ticket 
VALUES (6417, '29 Lame Street St. James', '04/17/2013', '04/25/2013', '05/01/2013', '04/25/2013', 'Expired License',121892053,128,100,121180);

UPDATE

Below is the code for the table:

CREATE TABLE ticket
(Ticket_id INTEGER PRIMARY KEY, 
location VARCHAR(20) NOT NULL, 
issue_datetime DATE NOT NULL,
due_datetime DATE NOT NULL, 
court_datetime DATE NOT NULL,
paid_datetime DATE NOT NULL, 
description VARCHAR(200) NOT NULL,
TRN int,
offense_id int,
parish_code int,
chassis_num int,
constraint fk_ticket foreign key (TRN) references driver(TRN), 
constraint fk_tickt foreign key (Offense_id) references Offense(Offense_id),
constraint fk_tiket foreign key (parish_code) references parish(pcode), 
constraint fk_ticet foreign key (chassis_num) references Cars(chassis_num)
);
2
  • One of your data exceeds the column's maximum number of characters. Commented Feb 27, 2015 at 0:19
  • 3
    One of the values you are inserting is too large for the field in your ticket table. Commented Feb 27, 2015 at 0:19

2 Answers 2

3

The column location has a limit of 20. The data you're trying to insert has a length of 24.

SELECT LEN('29 Lame Street St. James')

You might want to increase the limit for the location column.

ALTER TABLE [ticket] ALTER COLUMN [location] VARCHAR(255)
Sign up to request clarification or add additional context in comments.

Comments

1

Well we also need table information to know which field causes it but this essentially means that one field of your table does not have enough space for one of your insert strings.

If you paste your table info we can tell you which one it is.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.