Jason Follas.com

Page History: SQL Server XML Tricks


Compare Page Revisions



« Older Revision - Back to Page History - Current Revision


Page Revision: 2007/08/17 09:20


Intro

Here you will find a list of "tricks" and sample code for working with the XML data type in SQL Server 2005+. These topics are driven by audience member questions during my SQL/XML presentations.

Extract Element Names

An audience member wanted to query the XML data stored in a table in order to compare the list of elements from the XML in one row to another (presumably to detect if the untyped XML's "schema" changed from one row to another). Here's a way to generate a SQL table structure containing the namespace, local names, and parent's name for each element found in the table's XML. Once in this flat form, traditional SQL querying can be used to detect the changes.

Extract Element Names

ScrewTurn Wiki version 2.0.13. Some of the icons created by FamFamFam.