SQLXMLBulk Load

cneerr125

New Member
I'm trying to insert the following XML file into SQL Server 2008 using \[code\]SQLXMLBULKLOAD\[/code\]. The XML file is quite big so I've only posted a portion of the file. However, I'm having some problems with setting up the schema. When I try to run the program, it gives me an error stating: \[code\]Schema: relationship expected on 'datacol'\[/code\]. I tried to add the following relationship but i still receive an error. If someone could help out that would be great thanks!\[code\] <xs:annotation> <xs:appinfo> <sql:relationship name="TableRel" parent="UserCustomer" parent-key="id" child="UserCustomer" child-key="name2"/> </xs:appinfo> </xs:annotation>\[/code\]I have the table setup as this in SQL:\[code\]CREATE TABLE UserCustomer( name varchar(MAX), id int Primary KEY, datacol varchar(MAX), name2 varchar(MAX))\[/code\]XML\[code\]<all> <table> <record id="1001"> <datacol name="Status"> </datacol> <datacol name="pkey">0000000000e2zww2</datacol> <datacol name="active">1</datacol> <datacol name="bpamainhkey">0000320583</datacol> <datacol name="firstname">Steve</datacol> <datacol name="lastname">Zmudczynski</datacol> <datacol name="loginname">CORP\SXZMUDCZ</datacol> <datacol name="lppd">20120521</datacol> <datacol name="main">1</datacol> <datacol name="managementtype">Sales</datacol> <datacol name="validfrom">19000101</datacol> <datacol name="validthru">20120221</datacol> </record ></table></all>\[/code\]Schema:\[code\]<?xml version="1.0" encoding="iso-8859-1"?><xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="all"> <xs:complexType> <xs:sequence> <xs:element name="table"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="record"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="datacol" sql:relationship="TableRel"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="name" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="id" type="xs:unsignedShort" use="required" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element></xs:schema>\[/code\]
 
Back
Top