©  Alex Grinberg 2018
Alex GrinbergXML and JSON Recipes for SQL Serverhttps://doi.org/10.1007/978-1-4842-3117-3_5

5. Modifying XML

Alex Grinberg1 
(1)
Richboro, Pennsylvania, USA
 

XML XQuery has the ability to modify an XML instance for the XML variable and XML columns. The XQuery modify() method provides the ability to add, delete, and update the XML elements, attributes, and their values. This chapter will discuss and demonstrate real case scenarios to apply the modify() method for XML instances.

5-1. Inserting a Child Element into Your XML

Problem

You want to insert a child element into an existing XML instance.

Solution

You may encounter a situation in which you need to insert an XML element into an existing XML instance. Consider the simple XML data ...

Get XML and JSON Recipes for SQL Server: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.