I am using MS SQL Server 2012 and have the following XML structure:
<value name="parameter">
<![CDATA[__na__]]>
<![CDATA[1]]>
<![CDATA[2]]>
<![CDATA[3]]>
<![CDATA[12]]>
</value>
and it is saved in the database as string in NVARCHAR(MAX) data type field.
When I cast this value as follows:
CAST(ColumnValue AS XML)
I get the following XML structure:
<value name="parameter">__na__12312</value>
Is there a way to divide the CDATA with commas for exmaple and get the following structure:
<value name="parameter">__na__,1,2,3,12</value>
In my real case the string length can vary and I am using only part of the whole XML, so replacing each ']]>' with ']]>,' does not sound as good solution. Is there an other way to do this?