Advertisement

09.30.2008 at 11:33AM PDT, ID: 23775654
[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!

8.9

Import XML data into MS SQL 2000

Asked by TravelSmith in Extensible Markup Language (XML), MS SQL Server, XML Databases

Tags:

I have an XML file that contains transaction information from an outside vendor and need to create a style sheet to import it into MS SQL server 2000.  I found the following code to import XML data and it works well if you have your style sheet correct.

'VBScript to import XML to DB
Function Main()
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data source=ServerName;database=DBName;integrated security=SSPI"
objBL.ErrorLogFile = "c:\export\error.log"
objBL.KeepIdentity="False"
objBL.Execute "E:\DecisionMate\Schema.xml", "E:\DecisionMate\CheckoutReport.xml"
Set objBL = Nothing
      Main = DTSTaskExecResult_Success
End Function

These are the 2 tables that I have created to import into.

CREATE TABLE CATransactionInfo (
      [ID] INT IDENTITY,
      InvoiceNumber      INTEGER ,
      CheckoutDate       DATETIME,
      TotalInvoiceAmount MONEY)

CREATE TABLE CAShipment (
      InvoiceNumber      INTEGER,
      ShipmentNumber     INTEGER,
      ShipNameTitle      VARCHAR(20),
      ShipFirstName      VARCHAR(50),
      SKU                VARCHAR(20)
)

Can someone dirrect me as to what I am doing wrong in the style sheet?  I have gotten imports to work for the Transaction info, but can't seem to figure out how to link the Shipment info to it.

Thanks,Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
I have scaled down the XML for this example, but if the structure has been maintained.
 
<?xml version="1.0" encoding="iso-8859-1"?>
<CheckoutReport>
	<ReportId>36892</ReportId>
	<ReportPeriodStart>7/15/2003 12:00:00 AM (ET)</ReportPeriodStart>
	<ReportPeriodEnd>7/15/2003 11:00:00 AM (ET)</ReportPeriodEnd>
	<Version>2.0</Version>
	<PurchaseList>
		<BuyerPurchase>
			<TransactionInfo>
				<InvoiceNumber>5647151</InvoiceNumber>
				<CheckoutDate>07/15/2003 10:47:37 AM</CheckoutDate>
				<TotalInvoiceAmount>102.48</TotalInvoiceAmount>
			</TransactionInfo>
			<ShipmentList>
				<Shipment>
					<ShipmentNumber>1</ShipmentNumber>
					<ShipNameTitle>Dr.</ShipNameTitle>
					<ShipFirstName><![CDATA[Mark]]></ShipFirstName>
					<Items>
						<Item>
						<SKU><![CDATA[SCI1]]></SKU>
						</Item>
					</Items>
				</Shipment>
			</ShipmentList>
		</BuyerPurchase>
	</PurchaseList>
</CheckoutReport>
 
Here is the style sheet that I am trying to use and I can't get it to import.  Right now it returns the error: "The column 'ShipmentNumber' was definde in the schema, but does not exist in the database."
 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:annotation>
  <xsd:appinfo>
    <sql:relationship name="TransShip"
          parent="CATransactionInfo"
          parent-key="InvoiceNumber"
          child="CAShipment"
          child-key="InvoiceNumber" />
  </xsd:appinfo>
</xsd:annotation>
 
 
<xsd:element name="TransactionInfo" 
   sql:relation="CATransactionInfo" 
   sql:key-fields="InvoiceNumber" >
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="InvoiceNumber"       type="xsd:integer" />
      <xsd:element name="CheckoutDate"        type="xsd:date" />
      <xsd:element name="TotalInvoiceAmount"  type="xsd:string" />
      <xsd:element name="ShipmentNumber"      type="xsd:integer" 
			sql:relation="CAShipment" 
			sql:relationship="TransShip" />
      <xsd:element name="ShipNameTitle"       type="xsd:string"
			sql:relation="CAShipment" 
			sql:relationship="TransShip" />
      <xsd:element name="ShipFirstName"       type="xsd:string"
			sql:relation="CAShipment" 
			sql:relationship="TransShip" />
      <xsd:element name="SKU"       type="xsd:string"
			sql:relation="CAShipment" 
			sql:relationship="TransShip" />
    </xsd:sequence>
        <xsd:attribute name="InvoiceNumber" sql:field="InvoiceNumber" />
        <xsd:attribute name="CheckoutDate" sql:field="CheckoutDate" />
        <xsd:attribute name="TotalInvoiceAmount" sql:field="TotalInvoiceAmount" />
        <xsd:attribute name="ShipmentNumber" sql:field="ShipmentNumber" />
        <xsd:attribute name="ShipNameTitle" sql:field="ShipNameTitle" />
        <xsd:attribute name="ShipFirstName" sql:field="ShipFirstName" />
        <xsd:attribute name="SKU" sql:field="SKU" />
  </xsd:complexType>
</xsd:element>
</xsd:schema>
[+][-]09.30.2008 at 05:40PM PDT, ID: 22610711

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 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 05:49PM PDT, ID: 22610747

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 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 06:09PM PDT, ID: 22610857

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 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.01.2008 at 09:07AM PDT, ID: 22615909

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 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.01.2008 at 05:48PM PDT, ID: 22620404

View this solution now by starting your 14-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: Extensible Markup Language (XML), MS SQL Server, XML Databases
Tags: XML
Sign Up Now!
Solution Provided By: acperkins
Participating Experts: 1
Solution Grade: B
 
 
[+][-]10.02.2008 at 09:31AM PDT, ID: 22625856

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 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.02.2008 at 07:38PM PDT, ID: 22630647

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 14-day free trial to view this Expert Comment or ask the Experts your question.

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