Solved

Insert error...String greater than 8060.

Posted on 2002-03-05
4
435 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
2 Select Distinct 8 35
Returning data in a different format 8 45
SQL find overlapping events (by time) 2 25
T-SQL for SS2000 -- get characters until a digit 6 19
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

929 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

10 Experts available now in Live!

Get 1:1 Help Now