Posted By: Anonymous
I am running data.bat file with the following lines:
Rem Tis batch file will populate tables cdprogram filesMicrosoft SQL ServerMSSQL osql -U sa -P Password -d MyBusiness -i c:data.sql
The contents of the data.sql file is:
insert Customers (CustomerID, CompanyName, Phone) Values('101','Southwinds','19126602729')
There are 8 more similar lines for adding records.
When I run this with
c:data.bat, I get this error message:
1>2>3>4>5>....<1 row affected> Msg 8152, Level 16, State 4, Server SP1001, Line 1 string or binary data would be truncated. <1 row affected> <1 row affected> <1 row affected> <1 row affected> <1 row affected> <1 row affected>
Also, I am a newbie obviously, but what do
Level #, and
state # mean, and how do I look up error messages such as the one above: 8152?
From @gmmastros’s answer
Whenever you see the message….
string or binary data would be truncated
Think to yourself… The field is NOT big enough to hold my data.
Check the table structure for the customers table. I think you’ll find that the length of one or more fields is NOT big enough to hold the data you are trying to insert. For example, if the Phone field is a varchar(8) field, and you try to put 11 characters in to it, you will get this error.