Yukon XQuery question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken

    Yukon XQuery question

    I am trying to query data in an XML variable and I am having trouble
    getting the data out in the format that I would like. Given the
    following XML:
    declare @myDoc xml
    set @myDoc = '<Ownership
    TeamGuid="23EA3 93A-3926-4A55-8329-FE747593379D" TeamName=".NET
    Framework">
    <Roles>
    <Role Guid="93BDB4E2-95A0-438D-96E4-43032EB2BA16" Name="API Review
    PM Contact" ContactAlias="J ohn.Smith" Inherited="0" ArtifactName="" />
    <Role Guid="8A7145EF-B48B-4A93-BFA5-28B53995C022" Name="Architect "
    ContactAlias="J ohn.Doe" Inherited="0" ArtifactName="" />
    <Role Guid="BF727283-B18C-415A-A38C-CEC15CD341D9" Name="Corp VP"
    ContactAlias="N one" Inherited="0" ArtifactName="" />
    </Roles>
    </Ownership>'

    What I would like to do is run an XQuery against the variable and get
    attribute data back in normal rows and columns like the following:

    Guid Name
    ContactAlias
    ------------------------------------ ---------------------
    ------------
    93BDB4E2-95A0-438D-96E4-43032EB2BA16 API Review PM Contact John.Smith
    8A7145EF-B48B-4A93-BFA5-28B53995C022 Architect John.Doe
    BF727283-B18C-415A-A38C-CEC15CD341D9 Corp VP None

    I've checked the Query and Value methods and have not been able to get
    them to do this for me. Is this even possible w/XQuery? Do I need to
    use OpenXML to do what I am trying to accomplish?

    Thanks for your help!

  • David Portas

    #2
    Re: Yukon XQuery question

    Please post to the SQL Server 2005 groups:
    Our community is a collaborative place to learn about our products and ask questions! Check out our most popular conversations!


    --
    David Portas
    SQL Server MVP
    --


    Comment

    • Erland Sommarskog

      #3
      Re: Yukon XQuery question

      Ken (kenjohnson77@h otmail.com) writes:[color=blue]
      > I've checked the Query and Value methods and have not been able to get
      > them to do this for me. Is this even possible w/XQuery? Do I need to
      > use OpenXML to do what I am trying to accomplish?[/color]

      Look at the nodes() function.

      But as David said, you should use the specific SQL 2005 newsgroups for
      SQL 2005 questions. Not the least for XML/XQuery issues this can
      increase the quality of reponses dramatically. :-)


      --
      Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

      Books Online for SQL Server SP3 at
      Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

      Comment

      Working...