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 4583210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:10:58+00:00 2026-05-21T21:10:58+00:00

I am using InfoPath 2007 to send out a survey (it is not connected

  • 0

I am using InfoPath 2007 to send out a survey (it is not connected to SharePoint or a DataBase). The file I will get back is an XML file. Every place there is an answer block, it has its own unique id (aka field name).

Now, I have a SQL Server Database (2007?) with a table “Responses”. Its columns are: AnswerID(unique PK), QuestionID (FK) (which is the unique id (field name), and Answer. The QuestionID is already populated with the unique id (field name). There are more than 300 records for QuestionID.

What I need to be able to do is reach into the XML file, find the QuestionID (field name), grab the data for that field name, and then put the data into the DB column “Answer” that matches the field name in the QuestionID column.

Is there an easy/medium way to do this mapping/updating with the least amount of chance of error?

NOTE: I tried to use the DB import XML data wizard, the information breaks out into an unmanageable number of tables.

  • 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-21T21:10:59+00:00Added an answer on May 21, 2026 at 9:10 pm

    You can shred the XML into rows and columns and then use that to update your table.
    Here is a little example of what you can do.

    create table Responses(QuestionID varchar(10), Answer varchar(10))
    
    insert into Responses values('Q1', null)
    insert into Responses values('Q2', null)
    insert into Responses values('Q3', null)
    
    declare @xml xml
    set @xml = 
    '<root>
      <question ID="Q1">Answer1</question>
      <question ID="Q2">Answer2</question>
      <question ID="Q3">Answer3</question>
     </root>'
    
    ;with cte as
    (
      select 
        r.n.value('@ID', 'varchar(10)') as QuestionID,
        r.n.value('.', 'varchar(10)') as Answer
      from @xml.nodes('/root/*') as r(n)
    )
    update R
    set Answer = C.Answer
    from Responses as R
      inner join cte as C
        on R.QuestionID = C.QuestionID
    
    select *
    from Responses 
    

    Result:

    QuestionID Answer
    ---------- ----------
    Q1         Answer1
    Q2         Answer2
    Q3         Answer3
    

    The XML I used most certainly does not look anything like what you have but it should give you a hint of what you can do. If you post a sample of your XML file, table structure and expected result/output you can probably get a more precise answer.

    Edit

    declare @xml xml = 
    '<?xml version="1.0" encoding="UTF-8"?>
    <my:myFields xmlns:my="xx.com" xml:lang="en-us">
      <my:group1>
        <my:group2>
          <my:field1>Im an analyst.</my:field1>
          <my:group3>
            <my:group4>
              <my:field2>1</my:field2>
              <my:field3>I click the mouse.</my:field3>
            </my:group4>
            <my:group4>
              <my:field2>2</my:field2>
              <my:field3>I type on the keyboard.</my:field3>
            </my:group4>
          </my:group3>
        </my:group2>
        <my:group2>
          <my:field1>Im a stay at home mom.</my:field1>
          <my:group3>
            <my:group4>
              <my:field2>1</my:field2>
              <my:field3>I Cook.</my:field3>
            </my:group4>
            <my:group4>
              <my:field2>2</my:field2>
              <my:field3>I clean.</my:field3>
            </my:group4>
          </my:group3>
        </my:group2>
      </my:group1>
    </my:myFields>'
    
    ;with xmlnamespaces('xx.com' as my)
    select 
      T.N.value('../../my:field1[1]', 'varchar(50)') as Field1,
      T.N.value('my:field2[1]', 'varchar(50)') as Field2,
      T.N.value('my:field3[1]', 'varchar(50)') as Field3
    from @xml.nodes('my:myFields/my:group1/my:group2/my:group3/my:group4') as T(N)
    

    Result:

    Field1                 Field2       Field3
    Im an analyst.          1           I click the mouse.
    Im an analyst.          2           I type on the keyboard.
    Im a stay at home mom.  1           I Cook.
    Im a stay at home mom.  2           I clean.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using a file attachment control on a InfoPath form as part of a
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
System Specs: Infopath 2007 with c# code-behind Webservices Active Directory I need to get
I am trying to open an InfoPath 2007 file programmatically from a Windows service,
I am publishing a browser enabled Infopath form to Sharepoint server 2007. Once i
Using the below XML, I need to figure out which person worked more hours
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
I have an Infopath 2007 form with several views, meant to be used in
[SharePoint/MOSS 2007] I want to access several web services (on external sites, with WSDL
Has anybody ever successfully written code to extract data from a SharePoint 2007 list

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.