×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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

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

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

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

(OP)
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

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

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:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/startsql/portal_7ap1.asp

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

-SQLBill

Posting advice: FAQ481-4875

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

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close