Trying to export some data from SQL Server to an XML file. However when casting a VARCHAR
to XML
data type CDATA
section gets removed.
How can I keep the CDATA
?
Example:
SELECT CAST('<a><b>foo</b><c><![CDATA[<html><body>bar</body></html>]]></c></a>' AS xml)
Returns:
<a>
<b>foo</b>
<c><html><body>bar</body></html></c>
</a>