問題描述
我有一個包含 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 錯誤的方法)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!