Advertisement

04.03.2007 at 09:43AM PDT, ID: 22489622
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Load XML file into SQL Server 2000

Asked by PSIUnit in MS SQL Server, Extensible Markup Language (XML)

Tags: , , ,

I've been researching this situation for about a week, so any help that anyone could provide would be very much appreciated because I am beyond frustrated.  Before last week I knew absolutely nothing about xml.  The only files that I've loaded into my SQL Server have been .txt and .csv, so the xml format is way different.  

I've got an xml file that I need to take the data and load it into SQL Server 2000.  After researching, the way that makes most sense to me to load this data (and the example that I've gotten to work) is to have a VB script that uses the SQLXMLBulkLoad utility to load the data using a schema file that from what I can tell maps the data to the appropriate fields in the database.  So far, I created a schema file just of the xml file by using these instructions that I found on Experts:
1)      Put your XML file in an easy to find location (e.g. C:\temp\ )
2) Open Visual Studio Command Prompt (start> all programs> Visual Studio> Visual Studio tools> Visual Studio Command prompt)
3) enter: CD C:\temp
4) enter: XSD MyXmlFile.xml

This worked very well and I used the layout to create my SQL tables.  And I've got a VB script from an example that I found that runs the SQLXMLBulkLoad utility:
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data source=myserver;database=mydatabase;Trusted_Connection=Yes"
objBL.ErrorLogFile = "c:\error.log"
objBL.Execute "\\corp\lsw\xfer\format_files\NIPR_pdbbatch_schema.xml", "\\corp\lsw\xfer\import\NIPR_pdbbatch.xml"
Set objBL = Nothing

My problem is that I do not know how to make a good schema file.  I can't find a good tutorial that explains how to do exactly what I'm trying to do.  The file is very complicated and will result, apparently, in 10 separate tables.  The tables that I've created mimic the schema file:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="SCB_Report" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="SCB_Report" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="SCB_Report_Header">
          <xs:complexType>
            <xs:attribute name="Report_Type" type="xs:string" />
            <xs:attribute name="Title" type="xs:string" />
          </xs:complexType>
        </xs:element>
        <xs:element name="SCB_Report_Body">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="SCB_Partial_Find_List" type="xs:string" minOccurs="0" />
              <xs:element name="SCB_Producer" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Name_Birth" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Other_Name" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:attribute name="State_Code" type="xs:string" />
                              <xs:attribute name="Name" type="xs:string" />
                              <xs:attribute name="Name_Type" type="xs:string" />
                              <xs:attribute name="First_Name" type="xs:string" />
                              <xs:attribute name="Middle_Name" type="xs:string" />
                              <xs:attribute name="Last_Name" type="xs:string" />
                              <xs:attribute name="Name_Suffix" type="xs:string" />
                              <xs:attribute name="State_Id" type="xs:string" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="Primary_Name" type="xs:string" />
                        <xs:attribute name="First_Name" type="xs:string" />
                        <xs:attribute name="Middle_Name" type="xs:string" />
                        <xs:attribute name="Last_Name" type="xs:string" />
                        <xs:attribute name="Name_Suffix" type="xs:string" />
                        <xs:attribute name="Date_Of_Birth" type="xs:string" />
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="Address" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:attribute name="State_Code" type="xs:string" />
                        <xs:attribute name="Address_Type_Code" type="xs:string" />
                        <xs:attribute name="Address_Type" type="xs:string" />
                        <xs:attribute name="Address_Status" type="xs:string" />
                        <xs:attribute name="Date_Updated" type="xs:string" />
                        <xs:attribute name="Address_Line1" type="xs:string" />
                        <xs:attribute name="Address_Line2" type="xs:string" />
                        <xs:attribute name="Address_Line3" type="xs:string" />
                        <xs:attribute name="City" type="xs:string" />
                        <xs:attribute name="State" type="xs:string" />
                        <xs:attribute name="Zip_Code" type="xs:string" />
                        <xs:attribute name="Country" type="xs:string" />
                        <xs:attribute name="State_Id" type="xs:string" />
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="License" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="LOA" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:attribute name="LOA_Name" type="xs:string" />
                              <xs:attribute name="LOA_Code" type="xs:string" />
                              <xs:attribute name="LOA_Issue_Date" type="xs:string" />
                              <xs:attribute name="LOA_Status" type="xs:string" />
                              <xs:attribute name="LOA_Status_Reason" type="xs:string" />
                              <xs:attribute name="LOA_Status_Reason_Code" type="xs:string" />
                              <xs:attribute name="LOA_Status_Reason_Date" type="xs:string" />
                              <xs:attribute name="CE_Compliance" type="xs:string" />
                              <xs:attribute name="CE_Renewal_Date" type="xs:string" />
                              <xs:attribute name="CE_Credits_Needed" type="xs:string" />
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="Appointment" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:attribute name="Company_Name" type="xs:string" />
                              <xs:attribute name="FEIN_Cocode" type="xs:string" />
                              <xs:attribute name="FEIN" type="xs:string" />
                              <xs:attribute name="COCODE" type="xs:string" />
                              <xs:attribute name="Line_Of_Authority" type="xs:string" />
                              <xs:attribute name="LOA_Code" type="xs:string" />
                              <xs:attribute name="Status" type="xs:string" />
                              <xs:attribute name="Termination_Reason" type="xs:string" />
                              <xs:attribute name="Status_Reason_Date" type="xs:string" />
                              <xs:attribute name="Renewal_Date" type="xs:string" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="State_Code" type="xs:string" />
                        <xs:attribute name="Class" type="xs:string" />
                        <xs:attribute name="Date_Status_Effective" type="xs:string" />
                        <xs:attribute name="License_Class_Code" type="xs:string" />
                        <xs:attribute name="License_Number" type="xs:string" />
                        <xs:attribute name="License_Status" type="xs:string" />
                        <xs:attribute name="Resident_Indicator" type="xs:string" />
                        <xs:attribute name="License_Issue_Date" type="xs:string" />
                        <xs:attribute name="License_Expiration_Date" type="xs:string" />
                        <xs:attribute name="State_Id" type="xs:string" />
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="RIRS" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:attribute name="State_Code" type="xs:string" />
                        <xs:attribute name="Action_Id" type="xs:string" />
                        <xs:attribute name="Entity_Role" type="xs:string" />
                        <xs:attribute name="Origin_Of_Action" type="xs:string" />
                        <xs:attribute name="Reason_For_Action" type="xs:string" />
                        <xs:attribute name="Disposition" type="xs:string" />
                        <xs:attribute name="Date_Of_Action" type="xs:string" />
                        <xs:attribute name="Effective_Date" type="xs:string" />
                        <xs:attribute name="Enter_Date" type="xs:string" />
                        <xs:attribute name="File_Ref" type="xs:string" />
                        <xs:attribute name="Penalty" type="xs:string" />
                        <xs:attribute name="Length_Of_Order" type="xs:string" />
                        <xs:attribute name="State_RIRS_Id" type="xs:string" />
                        <xs:attribute name="State_Id" type="xs:string" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="National_Producer_Number" type="xs:string" />
                  <xs:attribute name="Secondary_ID" type="xs:string" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

So my question is, can someone show me how to make a schema file in the format that I need or is there a better way altogether to accomplish my objective?

Thanks,

Lena
Start Free Trial
[+][-]04.03.2007 at 10:47AM PDT, ID: 18845273

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2007 at 12:03PM PDT, ID: 18926659

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.17.2007 at 06:02PM PDT, ID: 18928641

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2007 at 06:10PM PDT, ID: 18928653

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2007 at 06:38PM PDT, ID: 18928764

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, Extensible Markup Language (XML)
Tags: sql, sqlxmlbulkload, xml, load
Sign Up Now!
Solution Provided By: acperkins
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.24.2008 at 09:48AM PDT, ID: 21857713

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.28.2008 at 04:56AM PDT, ID: 21890447

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32