Skip to content

Convert sql data to xml format

manuel joseph

Asked Jan 28, 2014, 9:08 PM EST1 answer
Share
LinkedInX
Hi,

I have data table in that table have a data that data will be convert in to xml format like
inside tag

example
 
<CPSMSStateSchemeMapping>
<StateCode>27</StateCode>
<FinancialYear>2013</FinancialYear>
<DepartmentCode>G</DepartmentCode>
<BudgetCode>0040000000000</BudgetCode>
<StateSchemeCode>24016241</StateSchemeCode>
< CPSMSSchemeCode>0404</CPSMSSchemeCode >
<CreatedDate >22/03/2013</CreatedDate>
</CPSMSStateSchemeMapping>
 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Sunny  Sharma
    0
    Hi Manuel,

    use the query below and you'll get the table data right into xml format as output:


    SELECT
    * 
    FROM 
    myTableName
    FOR XML AUTO,TYPE, ELEMENTS, ROOT('myTableName')

    Cheers!!
    0