We help IT Professionals succeed at work.
Get Started

string or binary data would be truncated

jvoconnell asked
Last Modified: 2015-02-25

The problem below has been coded to achieve the desired result. We are just looking for a definitive answer of why the error occurs.

We have a target table we are inserting into with a target column datatype of varchar(4).
We have a source table with the source column of datatype varchar(7).

In the source table all the records are 4 characters long except for one record which contains the value of "UNKNOWN".

We got the error that string or binary data would be truncated when running the insert. This made sense if one of the records being inserted was the record with the value of "UNKNOWN". That record wasn't explicitly excluded, but it wouldn't have been part of the data set being inserted. Why does the error get thrown?
Watch Question
SQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE