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?


- 在SQL中,如何为每个组选择前2行 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01