Sql Server 2005 Xml数据类型在INSERT上删除了CDATA

时间:2022-02-15 23:35:27

I have the following table in my database:

我的数据库中有以下表格:

CREATE TABLE [dbo].[XmlData](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [xmldata] [xml] NOT NULL,
CONSTRAINT [PK_XmlData] PRIMARY KEY CLUSTERED 
(
    [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

And when I run the following INSERT and SELECT statements I can see that my CDATA sections are being stripped somewhere along the line.

当我运行以下INSERT和SELECT语句时,我可以看到我的CDATA部分正在被删除。

INSERT 
    INTO 
        [XmlCdataTest].[dbo].[XmlData] ([xmldata])
    VALUES
        ('<doc><control><value><![CDATA[10 < 11]]></value></control></doc>')
GO

SELECT [xmldata] FROM XmlData
GO

Is this some sort of bug in SQL 2005 or is there some option I can use to tell SQL Server to not strip these cdata sections from my xml data?

这是SQL 2005中的某种错误,还是有一些选项可以告诉SQL Server不要从我的xml数据中删除这些cdata部分?

1 个解决方案

#1


It appears that there is no way around this.

似乎没有办法解决这个问题。

#1


It appears that there is no way around this.

似乎没有办法解决这个问题。