Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to build XML String from table values Expand / Collapse
Author
Message
Posted Wednesday, October 23, 2013 4:04 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, September 7, 2014 11:20 PM
Points: 132, Visits: 255
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!!!!!


Post #1507532
Posted Wednesday, October 23, 2013 4:33 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 1:49 AM
Points: 1,694, Visits: 19,551
SELECT para_value AS "PDTSHRTDE"
FROM Temp1
FOR XML PATH('PRODUCT'),ROOT('ROOT');



____________________________________________________

How to get the best help on a forum

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

Never approach a goat from the front, a horse from the rear, or a fool from any direction.
Post #1507536
Posted Wednesday, October 23, 2013 4:44 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, September 7, 2014 11:20 PM
Points: 132, Visits: 255
Thanks!!!!!!!!!!!!!!!
Post #1507542
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse