Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bulk load through SQLXML 3.0
Message
From
28/04/2005 04:44:35
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Import/Export
Title:
Bulk load through SQLXML 3.0
Miscellaneous
Thread ID:
01009129
Message ID:
01009129
Views:
60
Hi there

I'm trying to bulk load a ton of data into the db using SQLXML 3.0. My problem can best be described using an example from SQLXML help:
Create this table: 
CREATE TABLE Cust(CustomerID  int PRIMARY KEY,
                       CompanyName varchar(20),
                  City        varchar(20))
GO
Create a file in Notepad, and save it as SampleSchema.xml. To this file, add the following XSD schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:sql="urn:schemas-microsoft-com:mapping-schema">

  <xsd:element name="Customers" sql:relation="Cust" >
   <xsd:complexType>
     <xsd:sequence>
       <xsd:element name="CustomerID"  type="xsd:integer" />
       <xsd:element name="CompanyName" type="xsd:string" />
       <xsd:element name="City"        type="xsd:string" />
     </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
Create a file in Notepad, and save it as SampleXMLData.xml. To this file, add the following XML document:
<ROOT>
  <Customers>
    <CustomerID>1111</CustomerID>
    <CompanyName>Sean Chai</CompanyName>
    <City>NY</City>
  </Customers>
  <Customers>
    <CustomerID>1112</CustomerID>
    <CompanyName>Tom Johnston</CompanyName>
     <City>LA</City>
  </Customers>
  <Customers>
    <CustomerID>1113</CustomerID>
    <CompanyName>Institute of Art</CompanyName>
  </Customers>
</ROOT>
Create a file in Notepad, and save it as BLoad.vbs. To this file, add the VBScript code
set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.3.0")
objBL.ConnectionString = "provider=SQLOLEDB;data source=localhost;database=Northwind;integrated security=SSPI"
objBL.ErrorLogFile = "c:\error.log"
objBL.Execute "SampleSchema.xml", "SampleXMLData.xml"
set objBL=Nothing
Modify the connection string to provide the appropriate server and database name. Execute the script file.

This is working fine. Now, suppose the SampleXMLData.xml file looked like this:
<ROOT>
  <Customers>
    <CustomerID><data>1111</data></CustomerID>
    <CompanyName><data>Sean Chai</data></CompanyName>
    <City><data>NY</data></City>
  </Customers>
  <Customers>
    <CustomerID><data>1112</data></CustomerID>
    <CompanyName><data>Tom Johnston</data></CompanyName>
     <City><data>LA</data></City>
  </Customers>
  <Customers>
    <CustomerID><data>1113</data></CustomerID>
    <CompanyName><data>Institute of Art</data></CompanyName>
  </Customers>
</ROOT>
Notice that there are "data" tags around all values. What should the SampleSchema.xml look like then is what I need to figure out. I've tried several alternatives, but none with success.
Hope someone can shed some light on this.

Thanks
Danijel
Reply
Map
View

Click here to load this message in the networking platform