Solved

Insert error...String greater than 8060.

Posted on 2002-03-05
4
443 Views
Last Modified: 2010-05-18

Is there a way out to the following error:

Server: Msg 511, Level 16, State 1, Line 1
Cannot create a row of size 8247 which is greater than the allowable maximum of 8060.
The statement has been terminated.

I get the above error when i try to insert sql with a large string. Is there any other way out or i have to break my query into smaller parts?

Please advise.

Thanks.
0
Comment
Question by:soni1978
  • 2
4 Comments
 
LVL 32

Expert Comment

by:bhess1
ID: 6841942
The maximum size of a row in SQL Server is 8060 bytes.  If you have more data than that to store in one record, you need to use the text, ntext, or image data types to store the information.

This can be a problem if you define a record with a number of smaller fields that total more than 8060 bytes, e.g. 100 varchar(100) fields.  You can create a table like this (in this case, theoretically it could hold 10000 bytes).  However, if you place more than 8060 bytes in the record, the data will be truncated.

What is your data layout for the table?  Could you use a text field, or will you need to use more than one record?
0
 

Author Comment

by:soni1978
ID: 6844110

The table has 40 fields. There are 2 fields defined as varchar(5000) and 1 field defined as varchar(8000). It is not possible to change the table design as it is used by other system (but can change sizes if required)

The data comes from outside world in XML files. I have to interpret and insert in the database.
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6844495
Instead of using such big fields, use a Memo field (type TEXT in SQL)
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 100 total points
ID: 6845394
Agree with vindevogel.  

As I noted, the actual data in each row cannot exceed 8060 bytes, no matter what data types you use, unless you use the Text, nText, or Image data types.  If your total data length for all of the fields is > 8060, the insert will fail.

Now, if you change the Varchar(5000) and varchar(8000) fields to type Text, then the insert should work.  You may need to do an Insert and then an Update, since the SQL statement also has a maximum length (insert the other data, then update the long fields with the information).
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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 SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

829 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