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

  • Home
  • SEARCH
  • 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 6636391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:10:48+00:00 2026-05-25T23:10:48+00:00

I have a questionnaire stored in a XML column that I want to store

  • 0

I have a questionnaire stored in a XML column that I want to store in a non-xml table format instead. The source table looks like this:

ID          VERSION content
----------- ------- ---------------------------------------------------------------------
1211        96      <QS mg_id="1" locale_id="0" logoimg="inbox/FormImages/15/180.gif"...
1211        97      <QS mg_id="1" locale_id="0" logoimg="inbox/FormImages/15/180.gif"...

content:

<QS mg_id="1" locale_id="0" logoimg="inbox/FormImages/15/180.gif">
  <PAGE id="1" topic="Demographics" progress="9" background="inbox/FormImages/15/176.gif" lastPage="false" flush_concepts="1">
    <QUESTION id="2" type="dropdown" style="font-family:arial;font-size:12px;color:#086BB5;font-weight:bold;" value="What is your age?" defaultvalue="" listid="" conceptid="">
      <OPTIONS>
        <OPTION score="0" concept_value="1" value="I am under 18" url="" id="0" />
        <OPTION score="0" concept_value="2" value="Between 18 and 30 years old" url="" id="1" />
        <OPTION score="0" concept_value="3" value="Between 30 and 50 years old" url="" id="2" />
        <OPTION score="0" concept_value="4" value="Between 50 and 70 years old" url="" id="3" />
        <OPTION score="0" concept_value="5" value="Between 70 and 90 years old" url="" id="4" />
        <OPTION score="0" concept_value="6" value="Over 90 years old" url="" id="5" />
      </OPTIONS>
    </QUESTION>
    <QUESTION id="4" type="dropdown" style="font-family:arial;font-size:12px;color:#086BB5;font-weight:bold;" value="Do you have children?" defaultvalue="" listid="" tooltip="" usability="5">
      <OPTIONS>
        <OPTION score="0" concept_value="1" value="Yes" url="" id="0" />
        <OPTION score="0" concept_value="0" value="No" url="" id="1" />
      </OPTIONS>
    </QUESTION>
</PAGE>
</QS>

And I want to get output of the form:

ID          VERSION QuestionID QuestionValue     OptionID  OptionValue
----------- ------- ---------- ----------------- --------- -------------------------------
1211        96        2        What is your age?        1   I am under 18
1211        96        2        What is your age?        2   Between 18 and 30 years old
....
1211        96        4        Do you have children     1   Yes
....
1211        97        2 ...

Is there a way to do that using a select statement with SQL Server 2008?

  • 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-25T23:10:49+00:00Added an answer on May 25, 2026 at 11:10 pm

    Try this query:

    SELECT
        ID, 
        Version,
        Q.value('(@id)[1]', 'int') AS 'QuestionID',
        Q.value('(@value)[1]', 'varchar(50)') AS 'QuestionValue',
        OPT.value('(@id)[1]', 'int') AS 'OptionID',
        OPT.value('(@value)[1]', 'varchar(50)') AS 'OptionValue'
    FROM
        dbo.YourTableNameHere
    CROSS APPLY 
        XmlCol.nodes('QS/PAGE/QUESTION') AS QS(Q)
    CROSS APPLY
        QS.Q.nodes('./OPTIONS/OPTION') AS OPTS(OPT)
    

    You need to use two CROSS APPLY operators to

    • get a list of all <QUESTION> nodes inside your XML
    • get a sub-list of all <OPTION> nodes inside a given <QUESTION> to get the option information for each question
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have documents in Mongo that contain questionnaire-like data (company's name, address, phone numbers,
I have questionnaire data in, SQL Server 2008, that I want to transpose to
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have an ASP.Net questionnaire application that resubmits data to the same page, showing
I have an MVC questionnaire app that loops through a set of questions <%
We have a desktop app that allows users to fill in a questionnaire. For
We have a webapp performing questionnaire like scans. Entrance point is /app , which
I have a CakePHP website that acts as a questionnaire. It moves the user
I have a templated Gridview where I only want to display one column (Questions
I have a custom UITableViewCell that has a UISegmentedControl object. My UITableView (questionnaire form)

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.