views:

12

answers:

0

Hello, I am trying to bulk isnert XML Data into SQL Server 2008 Express with SQLXMLBulkLoad Object Model from C# (Visual Studio 2010).

My problem is that I am stuck with the relationships. Consider the following annotated XSD file:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                   xmlns:sql="urn:schemas-microsoft-com:mapping-schema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:annotation>
  <xs:appinfo>
    <sql:relationship name="CompanyEmployeeRel"
                      parent="Company"
                      parent-key="ID"
                      child="Employee"
                      child-key="CompanyID"/>
  </xs:appinfo>
</xs:annotation>
<xs:element name="Employee" sql:key-fields="ID">
  <xs:complexType>
    <xs:attribute name="ID" sql:datatype="uniqueidentifier"/>
    <xs:attribute name="FirstName" sql:datatype="nvarchar(255)" />
    <xs:attribute name="LastName" sql:datatype="nvarchar(255)"/>
  </xs:complexType>
</xs:element>
<xs:element name="Company" sql:key-fields="ID">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="Employee" sql:relationship="CompanyEmployeeRel"/>
    </xs:sequence>
    <xs:attribute name="ID" sql:datatype="uniqueidentifier"/>
    <xs:attribute name="Name" sql:datatype="nvarchar(100)"/>
  </xs:complexType>
</xs:element>
</xs:schema>

Then I let SQLXMLBulkLoad create the DB schema for me. This results in the following two tables:

alt text

The primary and foreign keys are correct as such; but my problem are the underlined columns. I specified that the ID column of the Company table should be a uniqueidentifier, but it is an nvarchar(40). Also the Name column is nvarchar(40) but I specified that it should be an nvarchar(100).

Does anybody know why this happens? And what I can do against this problem?

Regards