Inserting data to ntext xml column (Cannot call methods on ntext error)(将数据插入到 ntext xml 列(无法调用 ntext 错误的方法))
问题描述
我有一个包含 ntext
数据类型的 XML 列的表.
I have a table include XML column with ntext
data type.
CREATE TABLE #Testing
(
Id int identity,
content ntext
)
INSERT INTO #Testing
VALUES (N'<?xml version="1.0" encoding="UTF-8"?>
<Data <BankAcc><Bankname value="TEST Qərib Bank "/><AccNum value="TEST1221"/></BankAcc>
</Data>')
我想将此数据
插入到现有的ntext
数据类型xml 列中,代码如下
I want to insert this data <Owner value="Qərib"/>
into existing ntext
data type xml column with code below
update #Testing
set content.modify(N'insert <Owner value="Qərib"/> into (/Data)[1]')
但我收到一个错误:
消息 258,级别 15,状态 1,第 12 行
无法在 ntext 上调用方法
Msg 258, Level 15, State 1, Line 12
Cannot call methods on ntext
所以我尝试使用演员
update #Testing
set cast(content as varchar(max)).modify(N'insert <Owner value="Qərib"/> into (/Data)[1]')
然后我收到此错误消息:
then I got this error message:
消息 102,级别 15,状态 1,第 12 行
'(' 附近的语法不正确.
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near '('.
有什么解决办法吗?
推荐答案
将您的数据类型转换为 nvarchar(max)、varchar(max) 或 varbinary(max)
convert your data type to nvarchar(max), varchar(max) or varbinary(max)
重要!ntext、text 和 image 数据类型将在 SQL Server 的未来版本中删除.避免在新的开发工作中使用这些数据类型,并计划修改当前使用它们的应用程序.请改用 nvarchar(max)、varchar(max) 和 varbinary(max).
IMPORTANT! ntext, text, and image data types will be removed in a future version of SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.
参考
如果它是正确的 xml,那么 XML 数据类型将最适合
If it is proper xml then XML data type will fit best
这篇关于将数据插入到 ntext xml 列(无法调用 ntext 错误的方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将数据插入到 ntext xml 列(无法调用 ntext 错误的方


基础教程推荐
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 在多列上分布任意行 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01