Solved

Insert error...String greater than 8060.

Posted on 2002-03-05
4
444 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

730 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