Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi

I tried to save data of 4000 characters in sql db .
data type is varchar(4000) .
UI i had used asp text box .
Currently am able to save only 3946characters . In order to save 4000characters what i need to do .

Thanks in advance
Posted
Comments
Om Prakash Pant 9-Jul-12 9:05am    
can you show us the code that you tried so far?
Vinodh.B 9-Jul-12 9:24am    
ObjComments = commentEntryText.Text.Trim();
then build a insert query & assign it & insert the into db

It is definitely possible to save 4000 character comments to a varchar(4000) field. One possibility is that you have miscounted your characters. For instance, I believe line breaks count as a character, as do spaces and tabs.

To verify that this isn't a SQL issue, try doing an INSERT statement using the Query Editor. Use the REPLCIATE command to generate the requisite number of characters like so:
SQL
INSERT INTO yourTable (yourColumn) VALUES (REPLICATE('x', 4000));

If that query works (once you modify it to be accurate for your environment) then you know the issue is with the data you are sending in or with your application.

The only other issue I can think of is something to do with your SQL setup. Maybe you upgraded from SQL 2000 and you are still operating in SQL 2000 compatibility mode. If so, then the row size limit is 8060 bytes. Since varchar only takes up one byte per character (unlike nvarchar, which uses two), you would have to have a lot of data in the row besides the comments. However, it could be possible. If you are operating in SQL 2005 mode, then you won't have that issue since variable data can be up to 8MB I believe.
 
Share this answer
 
How about altering the target column in the database as nvarchar(max)[^]?
 
Share this answer
 
CAST('' as varchar(4000)) Solved the issue .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900