Get the names of attributes from an element in a SQL XML column

后端 未结 4 608
-上瘾入骨i
-上瘾入骨i 2021-02-06 10:36

For this xml (in a SQL 2005 XML column):


 1
 
 

4条回答
  •  忘了有多久
    2021-02-06 10:59

    this:

    declare @xml as xml
    
    set @xml = 
    '
     1
     
     
    '
    
    select @xml.query('
        for $attr in /doc/b/@*
        return local-name($attr)') 
    

    returns:

    ba bb bc

提交回复
热议问题