SQL Server

Extracting data from XML

Getting data from XML is much easier with native support of XML in SQL Server. But it still requires solid knowledge of XML specific things like XPATH or XQUERY. The goal of this article is to collect some useful examples of how to extract values from XML and save time when searching for it. Most of them are easy to understand and simple for copy and edit purposes.

1. Extracting values using .nodes method and XPATH navigation

Sample XML:

Extract User and Description values from the root element:


Extract values from inner elements. See how CROSS APPLY is used there.


Leave a Reply

Your email address will not be published. Required fields are marked *