Using attribute more than once in FOR XML Path T-SQL query with same element name

后端 未结 3 792
臣服心动
臣服心动 2021-01-26 18:41

I am trying to create an xml output in SQL 2008 using FOR XML Path. This is working fine:


      Clothing         


        
3条回答
  •  执笔经年
    2021-01-26 18:52

    I have another way. It seemed a tad bit easy to me. Say, for example I have an xml like

    DECLARE @xml xml=''
    
    DECLARE @multiplenodes XML = 'This is a test node 2This is another test node'
    
    SET @xml.modify('insert sql:variable("@multiplenodes") into (/parameters)[1]')
    
    SELECT @xml
    

    Do tell me if this helps.

提交回复
热议问题