sql - Select unique values of an xml attribute -


i have temp table 1 column of xml type.

how can write single select query list unique values of attribute 'z'

create table #test3 ([data] xml)  insert #test3 values ('<r><a z="1" /> <a z="2" /></r>')  insert #test  values ('<r><b z="2" /><b z="3" /></r>')  insert #test3 values ('<r><c z="3"><c z="4" /></c></r>') 

select distinct t.m.value( '@z[1]', 'varchar(max)' ) zattribute     #test3 temptable     cross apply temptable.data.nodes( '/your/node/path/here' ) t(m) 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -