Solved

SQL 2008 INSERT STATEMENTS

Posted on 2010-09-16
9
420 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 70

Expert Comment

by:Éric Moreau
ID: 33697509
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
ID: 33697586
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
ID: 33697600
HOw do i disable the option preventing to save changes to my table. I was trying to change the size
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 4

Expert Comment

by:timexist
ID: 33697606
you have to close the openning table, then you can save it.
0
 
LVL 3

Expert Comment

by:xiong8086
ID: 33697885
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
ID: 33699076
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
ID: 33701026

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

Expert Comment

by:parthmalhan
ID: 33710979
Please provide Table Definition/structure.
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34119902
Dear TAMSCODAN,

Any update ?

Raj
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

773 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