更新时间:2023-02-03 12:37:55
您的问题是:您的 XML 带有 encoding="utf-16"
,但您的列是非 Unicode 列......
Your problem is: you have XML with an encoding="utf-16"
, but your column is a non-Unicode column......
假设您也不能将其更改为 NTEXT
,则您必须执行两个嵌套的 CAST
来实现您想要的:
Assuming that you cannot change it to NTEXT
either, you have to do two nested CAST
to achieve what you're looking for:
SELECT
CAST(CAST(XML AS NTEXT) AS XML).value('(/Record/UserGuid)[1]', 'NVARCHAR(max)')
FROM
tbl_Module_RequestForms_Items
首先,您需要转换为NTEXT
(或NVARCHAR(MAX)
),然后您必须将该结果转换为XML
, 在您可以使用它之前.
First, you need to cast to NTEXT
(or NVARCHAR(MAX)
), and then you have to cast that result to XML
, before you can use it.
提示:删除那些其他原因"并将其转换为 XML
数据类型,如果您确实需要将其用作 XML .....
Tip: remove those "other reasons" and convert this to XML
datatype if you really need to use it as XML .....