Solved

SQL 2008 INSERT STATEMENTS

Posted on 2010-09-16
9
411 Views
Last Modified: 2012-05-10
I am having an error inserting the following data in SQL

USE ITD640_GP4

INSERT INTO customerTbl (customerID,customerFname,customerLname,customerTel,customerCity,customerState,customerZip)
Values
      ('114','Alan','Smith','3235','Mobile','Alabama','36509'),
      ('115','Kevin','Gordon','1124','Gulf Shores','Alabama','36535'),
      ('116','Paul','Connell','1212','Gulf Shores','Alabama','36535'),
      ('117','James','Sampson','1235','Alexandria','Louisiana','80977'),
      ('118','George','Ruiz','7532','Alexandria','Louisiana','80977'),
      ('119','Peter','Johnson','3254','Alexandria','Louisiana','80977'),
      ('120','Ben','Simpson','3241','Alexandria','Louisiana','80977'),
      ('121','Ken','Gordon','6643','New York','New York','70011')
      
      
SELECT * FROM customerTbl

The error that I am gettiong is

Msg 8152, Level 16, State 4, Line 4
String or binary data would be truncated.
The statement has been terminated.

(2 row(s) affected)

Any clues on what i can do to fix this matter.?
0
Comment
Question by:TAMSCODAN
9 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
how long are your character fields declared? you seem to try so store a value longer then the field max size
0
 
LVL 4

Expert Comment

by:timexist
Comment Utility
String or binary data would be truncated.
The statement has been terminated.

It means the value want to insert is larger than the max limitation of the field.
so you need to check the fields of customerTbl .

0
 
LVL 3

Author Comment

by:TAMSCODAN
Comment Utility
HOw do i disable the option preventing to save changes to my table. I was trying to change the size
0
 
LVL 4

Expert Comment

by:timexist
Comment Utility
you have to close the openning table, then you can save it.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:xiong8086
Comment Utility
I think your data is larger than the allowed size set for your column by definition.

if you want to turn off the exception
you may add:

set ANSI_WARNINGS OFF
GO
....

after scripts finished
....
set ANSI_WARNINGS ON
GO

you may execute without warning, but you may lose some data as it will be truncated if beyond the size limit.
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
Comment Utility
Increase the datatype length of the column which is causing this error. Then only the data you are trying to insert into the table will get inserted successfully. If you suppress the error warning messages, you will lose those data that you are inserting.

So better to first check and find which column have less datatype length than the size of the data you are inserting. Then increase its datatype length. That's all.

Raj
0
 
LVL 3

Accepted Solution

by:
jvejskrab earned 500 total points
Comment Utility

tools -> options -> designers -> table and database designers -> prevent saving changes.......
0
 
LVL 4

Expert Comment

by:parthmalhan
Comment Utility
Please provide Table Definition/structure.
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
Comment Utility
Dear TAMSCODAN,

Any update ?

Raj
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now