Sql query Output in XML format

  • I am not getting the output in desired format.

    I tried the solution that you provided. Do I need to do nested xml? to get the nodes as below:

    <entry emp_cd="4400" last_name="Passela" first_name="Lucia" user_name="4400" hiredate="01/01/2010" birthdate="01/01/1980" >

    <position code="1010" primary="Y" org_cd="5156" org_level_cd="STORE" eff_date="01/01/2010" />

    <status code="ACTIVE" eff_date="01/01/2010" />

    <payrate value="20.5" unit_cd="HOUR" type_cd="BASE" eff_date="01/01/2010"/>

    <schedplan code="NYFTH" eff_date="01/01/2010"/>

    <payplan code="NYFTH" eff_date="01/01/2010"/>

    </entry>

    </empload>

    Thanks.

  • lsurapaneni (12/28/2010)


    I am not getting the output in desired format.

    I tried the solution that you provided. Do I need to do nested xml? to get the nodes as below:

    <entry emp_cd="4400" last_name="Passela" first_name="Lucia" user_name="4400" hiredate="01/01/2010" birthdate="01/01/1980" >

    <position code="1010" primary="Y" org_cd="5156" org_level_cd="STORE" eff_date="01/01/2010" />

    <status code="ACTIVE" eff_date="01/01/2010" />

    <payrate value="20.5" unit_cd="HOUR" type_cd="BASE" eff_date="01/01/2010"/>

    <schedplan code="NYFTH" eff_date="01/01/2010"/>

    <payplan code="NYFTH" eff_date="01/01/2010"/>

    </entry>

    </empload>

    Thanks.

    That's strange...

    Your desired output looks almost exactly like the one you requested in an earlier post.

    Except for the fact of the missing header line info.

    Did you follow our advice and leave the data type as varchar(max) instead of xml (see Matt's most recent post)?

    If the data type still is varchar(max) and you used the code Wayne posted, what is the difference to your expected output? I simply can't find it...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Try the followinq Query :

    select * from empoyees

    order by emp_code

    for XML RAW ('Entry). This will bring the data in the Raw format. After that you have to add the encoding tag and make the output as a XML File.

Viewing 3 posts - 16 through 17 (of 17 total)

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