Retrieving XML element name using t-SQL Retrieving XML element name using t-SQL xml xml

Retrieving XML element name using t-SQL


Actually, sorry, the best I've got is:

select distinct r.value('fn:local-name(.)', 'nvarchar(50)') as tFROM    @xml.nodes('//quotes/*/*') AS records(r)

Guess I answered my own question...


DECLARE @xml as xmlSET @xml = '<Address><Home>LINE1</Home></Address>'SELECT Nodes.Name.query('local-name(.)') FROM @xml.nodes('//*') As Nodes(Name)

This will give the list of all elements