Sql Server 2005 Xml data type has CDATA removed on INSERT

半腔热情 提交于 2019-12-11 02:13:43

问题


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:


It appears that there is no way around this.



来源:https://stackoverflow.com/questions/735646/sql-server-2005-xml-data-type-has-cdata-removed-on-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!