无法在 SQL Server 的文本数据类型列中保存超过 43679 个字符 [英] Not able to save more than 43679 char in text datatype column in SQL Server

查看:22
本文介绍了无法在 SQL Server 的文本数据类型列中保存超过 43679 个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表中有一个 text 数据类型的列,并试图从 C# 代码中将一些字符串值保存到该列.当我使用一些非常大的字符串时会出现问题.

I have a column in table with text datatype and trying to save some string value to this column from C# code. Issue comes when I use some very large string.

我无法在文本字段中保存超过 43679 个字符.我知道 text 大小可以是 2^31.

I am not able to save more than 43679 character into text field. I know text size can be 2^31.

我也尝试从 SSMS 中保存相同的值并注意到相同的情况.

I also tried saving same value from SSMS and noticed same scenario.

代码没什么特别的,但是下面还是给出了SQL查询...

There is nothing special about code, but still SQL query is given below...

update TableName
set ColumnName = 'some text more than 43679 char'
where id=<some int id>

只是提...列在表中声明为

just to mention... column is declare in table as

[columnname] [text] NULL

谁能告诉我哪里出了问题.

Can anyone tell me what could be wrong.

推荐答案

您可以尝试使用 varchar(max) 来存储海量数据.请参阅 MSDN

You can try to use varchar(max) to store huge amount of data. See MSDN

我们建议您使用 varchar(max) 存储大数据,nvarchar(max) 或 varbinary(max) 数据类型.控制行内和这些数据类型的行外行为,使用大值类型 out行选项.

We recommend that you store large data by using the varchar(max), nvarchar(max), or varbinary(max) data types. To control in-row and out-of-row behavior of these data types, use the large value types out of row option.

您也可以在这里查看相同的问题:SSMS - 不能从网格模式的列中粘贴超过 43679 个字符

You can also check the same issue here: SSMS - Can not paste more than 43679 characters from a column in Grid Mode

这篇关于无法在 SQL Server 的文本数据类型列中保存超过 43679 个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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