A View Inside My Head

Jason's Random Thoughts of Interest
posts - 86, comments - 178, trackbacks - 22

Article: Extract Element Names from SQL Server XML Data

An audience member asked me if there was a way to be able to determine the element names that exist within the XML stored in a table. His business problem was that he archives XML in a field of a table, and needed to identify whether one row's XML contained a different set of elements than another row's (i.e., if an untyped XML's "schema" changed between versions). 

In this article, I demonstrate T-SQL and XQuery syntax that will generate a table structure containing a list of element names (per primary key value).  From this point, "traditional" querying can be used to detect changes in the XML's structure between rows.

http://www.jasonfollas.com/wiki/SQLXML_Tricks_ElementNames.ashx

 

Print | posted on Friday, August 17, 2007 9:44 AM | Filed Under [ Articles ]

Comments have been closed on this topic.

Powered by: