How to build XML String from table values

  • Hi,I am using Sql Server 2008 R2,

    My requirement is,

    I want to Execute the SP, with multiple value, which should be pass in XML format,

    and this values should taken from the following table.

    Create Table Temp1

    (

    para_namevarchar(100),

    para_valuevarchar(100),

    para_idint

    )

    Select * from Temp1

    Insert Into Temp1

    Values ('@AsonDate','HL', 26),

    ('@AsonDate','TL', 26),

    My desired Output XML query shuold be,

    <ROOT><PRODUCT><PDTSHRTDE>HLPDTSHRTDESC></PRODUCT>

    <PRODUCT><PDTSHRTDESC>TL/PDTSHRTDESC></PRODUCT>

    </ROOT>

    Can any one help,how to build this xml string.

    I need this urgently.

    Thanks in Advance!!!!!

  • SELECT para_value AS "PDTSHRTDE"

    FROM Temp1

    FOR XML PATH('PRODUCT'),ROOT('ROOT');

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Thanks!!!!!!!!!!!!!!!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply