Tag: Xml

Introduction to XML DML (Part 1) – Using the modify() method: insert
By Art on January 16, 2012

This is the first part of a 3 part blog which will attempt to show some different ways of how you can use the xml modify() method to update the contents of an XML document. This first part, starting at the absolute basics, will cover the ability to insert data into an existing XML document XML DML is an extension […]

Read More
Retrieving position() value of node by using XQuery alone
By Art on December 28, 2011

You can only use the position() function within an xquery predicate and can’t use it to return the position value of the node itself, which is a shame, but a couple of good workarounds have been published. However I had a requirement (don’t ask why!) to return the position() of the node as a value within the xml itself. My […]

Read More
FOR XML PATH using node tests in column aliases
By Art on December 15, 2011

I’ve used SQL to generate countless blobs of xml over the years and one feature that I have come to rely heavily upon is the ability to easily build complex xml structures by using column aliases in conjunction with the FOR XML PATH clause in your query. Not only do they allow for speedy creation, they also make the query […]

Read More
Simple XML exist performance enhancement
By Art on October 13, 2011

I came across this really simple best practice from BOL for the xml method exist which when used will give you a much cleaner and faster query plan. If like me you commonly use the name of an element or attribute as part of an XQuery predicate, then you would benefit immediately from this. So lets create a table with […]

Read More