Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3600470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:29:57+00:00 2026-05-18T20:29:57+00:00

I have the following XML: <query> <param weight=0.3> <item type=1 low=18 hi=20 pos=1 />

  • 0

I have the following XML:

<query>
  <param weight="0.3">
    <item type="1" low="18" hi="20" pos="1" />
    <item type="1" low="220" hi="220" pos="0" />
  </param>
  <param weight="0.7">
    <item type="2" low="5" hi="5" pos="1" />
  </param>
</query>

I want it to result in the following data set:

1   0.3 1   18  20  1
2   0.3 1   220 220 0
3   0.7 2   5   5   1

ROW_NUMBER() would make the row number. I’m only getting the first row (item[1]), but not the others. If I remove the ‘[1]’, I get a “singleton error”. How do I write this?

This is what I have so far:

SELECT  x.node.value('@weight', 'float') As [Weight],
        x.node.value('(item/@type)[1]', 'int') AS [Type],
        x.node.value('(item/@low)[1]', 'float') AS Low,
        x.node.value('(item/@hi)[1]', 'float') AS Hi,
        x.node.value('(item/@pos)[1]', 'bit') AS Pos
FROM    @Input.nodes('/query//*') AS x(node)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:29:57+00:00Added an answer on May 18, 2026 at 8:29 pm

    I figured it out with OPENXML:

    INSERT  INTO @ref
    SELECT  *
    FROM    OPENXML (@idoc, '/query/param/item', 2)
    WITH    ([Weight]   float   '../@weight',
            ParamType   int     '@type',
            Low         float   '@low',
            Hi          float   '@hi',
            Pos         bit     '@pos')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML: <query> <param weight=0.3> <item type=1 low=18 hi=20 pos=1 />
I have the following xml data: <portfolio> <item> <title>Site</title> <description>Site.com is a </description> <url>http://www.site.com</url>
I have the following XML <OrderReport> <Item> <Promotion> <Component> <Type>Principal</Type> <Amount currency=USD>-0.25</Amount> </Component> <Component>
I have following XML: <Library> <Item> <Field Name=Name>smooth</Field> <Field Name=File Type>mid</Field> <Field Name=File Size>60026</Field>
Say I have the following data I want to use in my FOR XML
I have the following XML data in SQLServer 2008 R2 DECLARE @data XML SET
I have an xml in following form: <?xml version=1.0 encoding=UTF-8?> <query> <queryParams name=accountID>Star TV</queryParams>
I have the following XML LINQ query from my XDocument. var totals = (from
I have following xml and I want to fetch the value of node which
I have following XML, and i wish to save its data in my SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.