How Do I Page And Sort When the TSQL Output is XML Tag

  • Hi,

    I am not able to find a proper solution to paging and sorting for XML outputs in 2005.

    After querying different tables

    I have the following output as XML

    '

    123

    test

    first

    1000

    second

    2000

    234

    abc

    first

    100

    second

    200

    '

    If I sort by InvetsorName tag2 should be the first tag, if I sort by order1 amount tag2 shoule be first, if I sort by order2 amount tag1 should be fisrt. How Do i achieve this.

  • You need to put XMl in code tags to be visible here, like this:

    123

    test

    first

    1000

    second

    2000

    234

    abc

    first

    100

    second

    200

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • I still seem to be failing to get the XML tags in readable format. Your help is much appreciated

  • Goto my earlier post (above) and hit the "QUOTE" button. This allows you to reply to a post, and also includes the whole thing quoted, as I originally wrote it (that's how I got your XML). In there you will see that I have enclosed your XML list in IFCode "code" tags that look like this:

    ... {your xml} ...[ /code]

    except that I have added an extra space in the closing one to keep them from activating so that they will stay visible. for this discussion.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • APARNA (5/17/2009)


    If I sort by InvetsorName tag2 should be the first tag, if I sort by order1 amount tag2 shoule be first, if I sort by order2 amount tag1 should be fisrt. How Do i achieve this.

    I try to convert your conclusion into XPath and the representing result (by investor id):

    You: If I sort by InvetsorName tag2 should be the first tag

    XPath: issue/investor/name

    Result: 234, 123

    You: if I sort by order1 amount tag2 shoule be first

    XPath: issue/investor/orders/order[1]/amount

    Result: 234, 123

    You: if I sort by order2 amount tag1 should be fisrt

    XPath: issue/investor/orders/order[2]/amount

    Result: 234, 123

    ... I used the XML posted by Barry (thanks! ;-)). investor "234" order2 has an amount of 200, investor "123" order2 has an amount of 2000.

    Greets

    Flo

  • Sorry to be replying very late on this issue, thank you for your comments, As I had to quickly deliver the project I converted into a data set by pivoting the results and ordered by accordingly.

    Thanks

    Aparna

Viewing 6 posts - 1 through 5 (of 5 total)

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