SQL: How can i get the value of an attribute in XML datatype

后端 未结 3 1346
南旧
南旧 2020-12-11 14:55

I have the following xml in my database:


  

I\'m using something like thi

3条回答
  •  攒了一身酷
    2020-12-11 15:00

    Use XQuery:

    declare @xml xml =
    '
      
    '
    
    select @xml.value('(/email/account/@language)[1]', 'nvarchar(max)')
    

    declare @t table (m xml)
    
    insert @t values 
        (''), 
        ('')
    
    select m.value('(/email/account/@language)[1]', 'nvarchar(max)')
    from @t
    

    Output:

    en
    fr
    

提交回复
热议问题