将XML读入SSIS中的SQL表

时间:2013-09-11 18:55:33

标签: sql xml ssis

我想读取XML文件并将数据拆分为父表和2个子表。以下是数据将进入的SQL架构和XSD。我在想SSIS是我想要使用但不确定如何去做。我应该遍历子项,然后使用代码插入行。任何想法都会有所帮助。我愿意使用SSIS以外的东西。我使用的是MS SQL Server 2008。

<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="MonthlyReportForm">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="unbounded">
          <xs:element minOccurs="0" name="ReportingDate" type="xs:string" />
          <xs:element minOccurs="0" name="ReportingYear" type="xs:unsignedShort" />
          <xs:element minOccurs="0" name="ReportingRegion" type="xs:string" />
          <xs:element minOccurs="0" name="TeamMembersName" type="xs:string" />
          <xs:element minOccurs="0" name="chkTraining" type="xs:unsignedByte" />
          <xs:element minOccurs="0" name="chkVernacularMaterials" type="xs:unsignedByte" />
          <xs:element minOccurs="0" name="RDHelpText" type="xs:string" />
          <xs:element minOccurs="0" name="chkOutOfCountryForm" type="xs:unsignedByte" />
          <xs:element minOccurs="0" maxOccurs="unbounded" name="TravelData">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" name="TravelRowLocation" type="xs:string" />
                <xs:element minOccurs="0" name="TravelRowTeam" type="xs:string" />
                <xs:element minOccurs="0" name="TravelRowThisMonth" type="xs:unsignedByte" />
                <xs:element minOccurs="0" name="TravelRowNextMonth" type="xs:string" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element minOccurs="0" name="TrainingReport">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="TrainingData">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element minOccurs="0" name="TrainerName" type="xs:string" />
                      <xs:element minOccurs="0" name="TraineeGender" type="xs:string" />
                      <xs:element minOccurs="0" name="TraineeAge" type="xs:decimal" />
                      <xs:element minOccurs="0" name="TraineeLanguage" type="xs:string" />
                      <xs:element minOccurs="0" name="TraineeEducation" type="xs:string" />
                      <xs:element minOccurs="0" name="TraineeProvince" type="xs:string" />
                      <xs:element minOccurs="0" name="TrainingPrepHrs" type="xs:decimal" />
                      <xs:element minOccurs="0" name="TrainingTrainHrs" type="xs:decimal" />
                      <xs:element minOccurs="0" name="TrainingArea" type="xs:unsignedByte" />
                      <xs:element minOccurs="0" name="TrainingActivity" type="xs:string" />
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

enter image description here

0 个答案:

没有答案