Reputation: 2166
I have a query which returns a column of XML values, for simplicity let's say this query is:
select top 1000 XmlColumn from MyTable
This returns a column with 1000 values, these contain XML.
I would like to extract the element name from only the top level element. So then I can transform these into a table of distinct element names.
How can I do this in one query?
Upvotes: 0
Views: 109
Reputation: 2296
select XmlColumn.value('local-name(/*[1])','varchar(100)')
from MyTable
Upvotes: 2