[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Insert error...String greater than 8060.

Posted on 2002-03-05
4
Medium Priority
?
460 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:Brendt Hess
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:
Brendt Hess earned 300 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

656 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