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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:25:36+00:00 2026-05-28T07:25:36+00:00

I have a problem. I have a SQL Server table that stores a bunch

  • 0

I have a problem. I have a SQL Server table that stores a bunch of XML documents in a column. I need to pass these XML documents to a XML parser, but the format of my starting XML is not in a format the parser can accept. Here’s what I have to work with –

XML stored in my SQL Server table is in the following format:

<Document ID="207">
  <Version>1.0</Version>
  <LastModifiedInVersion>1.0</LastModifiedInVersion>
  <Signatures />
  <Controls>
    <Control ID="EmpID">
      <Value>45678</Value>
    </Control>
    <Control ID="EmpFN">
      <Value>Ryn</Value>
    </Control>
    <Control ID="EmpLN">
      <Value>Veris</Value>
    </Control>
    <Control ID="EmpDOB">
      <Value>01/19/1980</Value>
    </Control>
  </Controls>
  <AutoKeys />
</Document>

I need to take that XML and make it look like this:

<xml_record>
<employee>
    <EmpID value="45678"/>
    <EmpFN value="Ryn"/>
    <EmpLN value="Veris"/>
    <empDOB value="01/19/1980"/>
</employee>
</xml_record>

I looked into using XSLT, but it seems to be all based around displaying XML data in a browser and not a translation of the actual format. My ultimate goal is simply to translate the format and use the XML parser to pull the employee values to populate another table, I don’t need any of the rest of the original XML. Is what I’m looking to do even possible? If so just pointing me in the right direction would be great.

  • 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-28T07:25:37+00:00Added an answer on May 28, 2026 at 7:25 am

    Try this:

    DECLARE @xdoc xml = '<Document ID="207">
      <Version>1.0</Version>
      <LastModifiedInVersion>1.0</LastModifiedInVersion>
      <Signatures />
      <Controls>
        <Control ID="EmpID">
          <Value>45678</Value>
        </Control>
        <Control ID="EmpFN">
          <Value>Ryn</Value>
        </Control>
        <Control ID="EmpLN">
          <Value>Veris</Value>
        </Control>
        <Control ID="EmpDOB">
          <Value>01/19/1980</Value>
        </Control>
      </Controls>
      <AutoKeys />
    </Document>
    '
    
    
    SELECT 
        EmpID   'EmpID/@value',
        EmpFN    'EmpFN/@value',
        EmpLN    'EmpLN/@value',
        EmpDOB   'EmpDOB/@value'
    FROM (
    SELECT 
        @xdoc.query('//Control[@ID = "EmpID"]/Value').value('.','INT') AS EmpID,
        @xdoc.query('//Control[@ID = "EmpFN"]/Value').value('.','VARCHAR(100)') AS EmpFN,
        @xdoc.query('//Control[@ID = "EmpLN"]/Value').value('.','VARCHAR(100)') AS EmpLN,
        @xdoc.query('//Control[@ID = "EmpDOB"]/Value').value('.','VARCHAR(100)') AS EmpDOB
    )t
    FOR XML PATH('employee'), ROOT('xml_record')
    

    Not most elegant, but working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL Server, I have a table where a column A stores some data.
I have a SQL Server database with a table that has a column that
Possible Duplicate: SQL Server Database query help Hi, I have a problem that I
Description: I have a column(EmailsAdress) on a table(BusinessUsers) on my databases that stores email
I have a SQL Server table full of orders that my program needs to
I have a table in a SQL Server 2005 Database that is used a
In SQL Server 2005, I have a query that involves a bunch of large-ish
We have an application which stores its data in SQL Server. Each table has
I have a table in my SQL Server DB that holds auditing information for
I have a table in Sql Server that contain an int field price that

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.