Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error, string or binary data would be truncated when trying to insert 1

Status
Not open for further replies.

Rousseau10

Programmer
Feb 22, 2005
242
US
I am running data.bat file with the following lines:


Rem Tis batch file will populate tables

cd\program files\Microsoft SQL Server\MSSQL
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 in actually start > run > cmd > 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 newbee obviously, but what dowa Level #, and state# mean. and how do I look up error messages such as the one above: 8152???
Thanks in advance!!!


I was the first American Soldier to put a basketball hoop up in Iraq, only to have it stolen by a soldier from different camp. Newbee - Adam
 
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.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
thanks geroge , what is the difference binary data and string data? Is binary 1 bit, on and off?

I was the first American Soldier to put a basketball hoop up in Iraq, only to have it stolen by a soldier from different camp. Newbee - Adam
 
No. Binary is 1's and 0's. BIT data type is 'yes'/'no' or 'on'/'off'.

I suggest you make the BOL your friend, you can find lots of your answers there.

BOL=Books OnLine=Microsoft SQL Server's HELP
Installed as part of the Client Tools
Found at Start>Programs>Microsoft SQL Server>Books OnLine
or online at:

Look up error messages in the BOL or on Microsoft's SQL Server website.

-SQLBill

Posting advice: FAQ481-4875
 
thanks SQLBill

I was the first American Soldier to put a basketball hoop up in Iraq, only to have it stolen by a soldier from different camp. Newbee - Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top