保存长度为4000个字符的注释 [英] To save comments of length of 4000 characters

查看:127
本文介绍了保存长度为4000个字符的注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图在sql db中保存4000个字符的数据.
数据类型为varchar(4000).
UI我使用过asp文本框.
目前仅能保存3946个字符.为了节省4000个字符,我需要做些什么.

在此先感谢

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

推荐答案

绝对有可能将4000个字符的注释保存到varchar(4000)字段中.一种可能是您误算了您的角色.例如,我相信换行符和空格和制表符一样都是字符.

要验证这不是SQL问题,请尝试使用查询编辑器执行INSERT语句.使用REPLCIATE命令生成所需数量的字符,如下所示:
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:
INSERT INTO yourTable (yourColumn) VALUES (REPLICATE('x', 4000));


如果该查询有效(一旦您对其进行了修改以使其适合您的环境),那么您就知道问题出在与您发送的数据或与应用程序一起发送的数据.

我能想到的唯一其他问题与您的SQL设置有关.也许您是从SQL 2000升级的,但仍在SQL 2000兼容模式下运行.如果是这样,则行大小限制为8060字节.由于varchar每个字符仅占用一个字节(与nvarchar使用两个字符不同),因此除了注释之外,您还必须在该行中包含大量数据.但是,这是可能的.如果您以SQL 2005模式操作,那么您不会遇到该问题,因为我相信可变数据最多可以达到8MB.


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.


如何将数据库中的目标列更改为 nvarchar(max) [ ^ ]?
How about altering the target column in the database as nvarchar(max)[^]?


CAST(''''as varchar(4000))解决了该问题.
CAST('''' as varchar(4000)) Solved the issue .


这篇关于保存长度为4000个字符的注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆