我在表中有 xml 列。当我将 xml 插入表中时,xml 中的所有符号都是正常的。但是,当我尝试使用 Xml DML 语句将节点插入 xml 时,如果该节点具有像“Delta”这样的符号,SqlServer 会将它们转换为问号。谁能建议如何解决这个问题?
这是示例代码:
-- 1. 创建表
CREATE TABLE SAMPLE_XML(ID INT IDENTITY, Information xml);
-- 2. 创建一个存储过程,将数据插入到表中。
CREATE PROCEDURE [dbo].[SET_SAMPLEXML]
@Information xml
AS
BEGIN
INSERT INTO SAMPLE_XML
(Information)
VALUES
(@Information);
END
--3. execute stored procedure to insert data, delta symbol gets recognized
EXEC SET_SAMPLEXML
@Information = N' <tr>
<td>Δcardia info</td>
</tr>';
--4 Now, insert one more node with delta symbol. SqlServer converts it into ? mark.
UPDATE SAMPLE_XML
SET Information.modify('insert (<td>Δinput</td>) as first into (tr)[1]') WHERE
ID=1;
--5 The result of the select statement of the table. Please observe, newly inserted td tag has the delta symbol converted into ? mark.
<tr>
<td>?input</td>
<td>Δcardia info</td>
</tr>