Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to build XML String from table values


How to build XML String from table values

Author
Message
avdhut.k
avdhut.k
SSC-Enthusiastic
SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)

Group: General Forum Members
Points: 141 Visits: 266
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_name   varchar(100),
para_value   varchar(100),
para_id   int
)

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!!!!!
Mark Cowne
Mark Cowne
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2090 Visits: 22778

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




avdhut.k
avdhut.k
SSC-Enthusiastic
SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)SSC-Enthusiastic (141 reputation)

Group: General Forum Members
Points: 141 Visits: 266
Thanks!!!!!!!!!!!!!!!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search