Advertisement

03.19.2008 at 09:14AM PDT, ID: 23254167
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

How do you do an openxml insert statemement from a multi data level xml file?

Asked by audExpert in SQL Server 2005, Extensible Markup Language (XML)

Tags:

I have an xml data file.  I have a t-sql stored procedure that uses openxml to do an insert based on this data.  The procedure inserts data but not correctly.  Only the data from the first level of the xml file gets inserted.  Data nested under the first level all gets inserted into one field.  My question is, how do I write the openxml so that data goes into the correct fields?

Next you will see the data file.  You will see that the "2nd tier" of data starts at the <Page> tag.  All the data under this tag is nested under <Page> and other levels; it's hard to see the way it is pasted here.  When I do the insert, every piece of data under this tag all gets put into one field in the target table, the Page field.  I want it all to go into its respective fields.  Here is the xml data file.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <JV xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <JVNo>1</JVNo>
  <Preparer>Dirk</Preparer>
  <Date>03/08/2008</Date>
- <Page>
  <PageNo>1</PageNo>
- <Entry No="1">
  <AT>22</AT>
  <Fund>110</Fund>
  <Agency>100</Agency>
  <Org>1100</Org>
  <Object>2410</Object>
  <Debit>50000</Debit>
  <Credit>0</Credit>
  <Annotation>This is a test</Annotation>
  </Entry>
- <Entry No="2">
  <AT>31</AT>
  <Fund>320</Fund>
  <Agency>110</Agency>
  <Org>1101</Org>
  <Object>3210</Object>
  <Debit>0</Debit>
  <Credit>50000</Credit>
  <Annotation>This is a test</Annotation>
  </Entry>
  </Page>
  <Comments>This is a test jv</Comments>
  <GrandDebit>50000</GrandDebit>
  <GrandCredit>50000</GrandCredit>
  </JV>

Following is the sql that does the insert.

INSERT INTO JV_TEST
SELECT *
FROM OPENXML (@rDoc,'/JV',3) WITH JV_Test

And here is the offending result; you can't tell but again, all of the data under the page tag got put into one field, the Page field.

NULL      Dirk      NULL      1 22 110 100 1100 2410 50000 0 This is a test 31 3      NULL      NULL      NULL      NULL      NULL      NULL      NULL      NULL      NULL      NULL      50000      50000

The target table has a field available for each piece of data.  How do I write the openxml so that data gets put into the correct fields? Start Free Trial
[+][-]03.19.2008 at 09:43AM PDT, ID: 21163233

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 10:57AM PDT, ID: 21164007

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 11:21AM PDT, ID: 21164232

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03.19.2008 at 11:26AM PDT, ID: 21164269

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 11:30AM PDT, ID: 21164303

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 12:21PM PDT, ID: 21164890

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 12:23PM PDT, ID: 21164904

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 12:26PM PDT, ID: 21164946

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 12:29PM PDT, ID: 21164984

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 02:05PM PDT, ID: 21165891

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2005, Extensible Markup Language (XML)
Tags: T-SQL OPENXML
Sign Up Now!
Solution Provided By: audExpert
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.19.2008 at 02:08PM PDT, ID: 21165916

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 02:13PM PDT, ID: 21165973

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 02:43PM PDT, ID: 21166204

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628