I need to load an XML file for comparison into SQL Server 2000. I have worked through the examples and have successfully loaded to a table. My problem is that my XML isn't quite laid out the way the examples are. When I have a repeating element I receive and error. I need to know how to configure the data mapping schema to handle this. I've worked up an example of what I'm trying to do, including the table to be loaded the xml file, the schema, and the error I'm receiving.Table:CREATE TABLE [Customer] ( [CustomerId] [int] NOT NULL , [CompanyName] [nvarchar] (20), [City] [nvarchar] (20), [State] [nvarchar] (2))GO
XML:<ROOT> <Customers CustomerId="1111"> <Company CompanyName="Sean Chai" /> <CityName City="NY" State="NY"/> <CityName City="Buffalo" State="NY"/> <!-- repeat element that errors--> </Customers> <Customers CustomerId="1112"> <Company CompanyName="Tom Johnston" /> <CityName City="LA" State="CA"/> </Customers> <Customers CustomerId="1113"> <Company CompanyName="Institute of Art"/> <CityName City="DC" State="DC"/> </Customers></ROOT>
XDR:<?xml version="1.0" ?><Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:xml:datatypes" xmlns:sql="urn:schemas-microsoft-com:xml-sql" > <AttributeType name="CustomerId" dt:type="int" /> <AttributeType name="CompanyName" dt:type="string" /> <AttributeType name="City" dt:type="string" /> <AttributeType name="State" dt:type="string" /> <ElementType name="ROOT" sql:is-constant="1"> <element type="Customers" /> </ElementType> <ElementType name="Company" sql:relation="Customer"> <attribute type="CompanyName" /> </ElementType> <ElementType name="CityName" sql:relation="Customer"> <attribute type="City" /> <attribute type="State" /> </ElementType> <ElementType name="Customers" sql:relation="Customer"> <attribute type="CustomerId" sql:field="CustomerId" /> <element type="Company" sql:field="CompanyName" /> <element type="CityName" sql:field="City" /> </ElementType> </Schema>
Error recieved from XML BULK LOAD:Data mapping to column 'City' was already found in the data. Make sure that no two schema definitions map to the same column.I'm sure that this is something simple to fix, I'm just not proficient with XML at all. Any help would be appreciated. It works perfectly as long as the CityName element only occurs once, but in the data I'm trying to load there may be 1 to n occurrence of an element within the parent.Thanks for any assistance....KEG...