SQL Server Text Datatype Maxlength = 65,535?(SQL Server 文本数据类型 Maxlength = 65,535?)
问题描述
我正在使用的软件使用文本字段来存储 XML.从我的在线搜索来看,文本数据类型应该包含 2^31 - 1 个字符.目前,SQL Server 每次都将 XML 截断为 65,535 个字符.我知道这是由 SQL Server 引起的,因为如果我直接在 Management Studio 中向列中添加第 65,536 个字符,它会声明它不会更新,因为字符将被截断.
Software I'm working with uses a text field to store XML. From my searches online, the text datatype is supposed to hold 2^31 - 1 characters. Currently SQL Server is truncating the XML at 65,535 characters every time. I know this is caused by SQL Server, because if I add a 65,536th character to the column directly in Management Studio, it states that it will not update because characters will be truncated.
最大长度真的是 65,535 还是因为数据库是在早期版本的 SQL Server (2000) 中设计的,并且它使用旧的 text
数据类型而不是 2005 的数据类型?
Is the max length really 65,535 or could this be because the database was designed in an earlier version of SQL Server (2000) and it's using the legacy text
datatype instead of 2005's?
如果是这种情况,在 SQL Server 2005 中将数据类型更改为 Text
会解决这个问题吗?
If this is the case, will altering the datatype to Text
in SQL Server 2005 fix this issue?
推荐答案
这是 SSMS 的限制,而不是文本字段,但您应该使用 varchar(max),因为文本已被弃用
that is a limitation of SSMS not of the text field, but you should use varchar(max) since text is deprecated
这里也是一个快速测试
create table TestLen (bla text)
insert TestLen values (replicate(convert(varchar(max),'a'), 100000))
select datalength(bla)
from TestLen
为我返回 100000
Returns 100000 for me
这篇关于SQL Server 文本数据类型 Maxlength = 65,535?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server 文本数据类型 Maxlength = 65,535?


基础教程推荐
- 带有WHERE子句的LAG()函数 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01