I have a table with a column of type ntext. This column contains xml as string
I want to delete one element that can exists more than once.
How do I do that?
Example xml input:
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
</CATALOG>
I want to delete the node COUNTRY with a SQL update script
ntext,text, andimagedata types will be removed in a future version of SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Usenvarchar(max),varchar(max), andvarbinary(max)instead. See details here. And if your column really contains XML - you should really use theXMLdatatype in SQL Server 2005 and newerntext(which should never be) its contents is just a chunk of text. There is no way other than parse it and remove the nodes on your own. The best solution is to change it toxmlcolumn and use specialized methods, but if that's not possible, I suppose the next best alternative is to do it client-side, using dedicated xml parsing functions.