Sql Server 2005 Xml data type has CDATA removed on

2019-07-14 06:36发布

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 
    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?

1条回答
贪生不怕死
2楼-- · 2019-07-14 07:00

It appears that there is no way around this.

查看更多
登录 后发表回答