I want to remove empty tags:
<name></name>
from an xml type field in a table. Can I do it using a query and a modify?Use the modify method and the XQuery delete instruction as follows (uses an XML variable but can of course also be done with a column of type XML):
Code Snippet
DECLARE @.xml xml;
SET @.xml = '<root>
<name/>
<name></name>
<element>
<name />
</element>
</root>';
SET @.xml.modify('
delete //*[not(node())]
');
SELECT @.xml;
|||PERFECT!!! I am thrilled. Easy and simple and solved my problem.
No comments:
Post a Comment