Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

help with xml

$
0
0

Need

 I'm having the data as shown below. I want table results in the form of xml .So I'mUSINGXMLPATHTOGETtheresults.ButI'm looking for speciifc format .'


--Declare a table variable

DECLARE@ProcessingTABLE(CaseDataKeyINTIDENTITY(1,1)PRIMARYKEY

,CaselistVARCHAR(8));


        


--Populate the table variable with the list of Caselist


INSERTINTO@Processing(Caselist)

SELECT '23456' UNIONALLSELECT '4321'

SELECT*FROM@Processing

FORXMLPATH('Results')

above

querywillgivemether esults ASshownbelow:

above querywillgivemether esults ASshownbelow:

<Results>

<CaseDataKey>1</CaseDataKey>

<Caselist>23456</Caselist>

</Results>

<Results>

<CaseDataKey>2</CaseDataKey>

<Caselist>4321</Caselist>

</Results>

I wantTOGETtheresultsASshownbelow:

<Results>

<InfofieldName="CaseDataKey"Value="1"/>

<InfofieldName="Caselist"Value="23456"/>

</Results>

<Results>

<InfofieldName="CaseDataKey"Value="2"/>

<InfofieldName="Caselist"Value="4321"/>

</Results>

how should IMODIFYthequeryTOaccommodateaboveresults.


 


 


 


 


 

 


 


 

 

 


 

 

 

 


 


  



 


 



 

 

 


 






Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>