String or binary data would be truncated in table

Recently, I attempted to insert a record into a table in SQL Server. After executing the insert query, I received the error ‘String or binary data would be truncated in table.’

String or binary data would be truncated in table

I was trying to execute the following insert query.

Declare @InitialVisitDate DATE = '2025-06-18';
INSERT INTO Appointments (PatientID, AppointmentDate, Purpose)
VALUES (
    98765,
    DATEADD(DAY, 1, @InitialVisitDate),
    'Follow-up Consultation'
);

After executing the above query, I encountered the error shown in the screenshot below.

String or binary data would be truncated in table

Solution

The reason for this error VARCHAR size of the Purpose column in the Appointments table was one, but I was trying to insert a more lengthy value for the purpose column, so I got this error. Check out the screenshot below.

string or binary data would be truncated in table in sql

To fix this issue, I have updated the varchar size of the purpose column using the following query.

ALTER TABLE Appointments ALTER COLUMN Purpose VARCHAR(200);

The query executed successfully as shown in the screenshot below.

sql string or binary data would be truncated in table

The column’s varchar value has been updated successfully, as shown in the screenshot below.

sql server string or binary data would be truncated in table

Now, the same insert query has been executed successfully as shown in the screenshot below.

string or binary data would be truncated in table sql

The same record has been successfully inserted into the table, as shown in the screenshot below.

error string or binary data would be truncated in table

You may also like the following articles.