Get data from XML using XQuery

  • Hi guys,

    I have a small problem 🙂

    I have a stored procedures which has an input parameter @XmlDocumet of type XML.

    The xml looks like this:

    How can i retrieve the information, using one select statement and XQuery methods, so i have the rows like this:

    First_Name Last_Name Age

    Oana Schuster 25

    Daniel Marti 26

    Is it possible?

    Thanks in advance 🙂

    Oana.

  • I don't know what happend with the xml example 🙁

    Schuster</Last_Name?

    Marti</Last_Name?

  • wow 🙁

    I hope this time you can see the xml example.

    Sorry ...

  • select r.value('First_Name[1]','varchar(10)') as First_Name,

    r.value('Last_Name[1]','varchar(10)') as Last_Name,

    r.value('Age[1]','int') as Age

    from @Xmldocument.nodes('/Data/Customer') as d(r)

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Thank you so so so much 🙂

    Oana.

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

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