Article ID: 316005 - Last Review: December 23, 2005 - Revision: 4.4 How to import XML into SQL Server with the XML Bulk Load componentThis article was previously published under Q316005 On This PageSUMMARY Data that is expressed in XML can be loaded into a Microsoft SQL
Server 2000 database by using the XML Bulk Load component. This article
outlines the steps that you need to follow to load XML data into a table that
already exists in the database. Note If you are using Microsoft SQL Server 2005, see the "XML Bulk Load Examples" topic in SQL Server 2005 Books Online. RequirementsTo use the steps in this article you need:
Create table to receive the dataUse the following steps to create a table to receive the data that the XML Bulk Load component processes.
Create the XML data source fileThis is the sample data source code. Paste this XML into Notepad, and then save the file as C:/Customers.xml.Create the mapping schema fileThis next file is a file that you use to map the format of the data source XML to the format of the Customer table in the database. Paste this XML into Notepad, and then save the file as C:/Customermapping.xml.Create a VBScript program to execute the XML Bulk Load componentThis is the script that uses the XML Bulk Load component to insert the three records you created in the "Create the XML Data Source File" heading into the table you created in the "Create Table to Receive the Data" heading by using the mapping schema discussed in the "Create the Mapping Schema File" heading. Paste this VBScript code into Notepad, and then save the file as C:\Insertcustomers.vbs. Error connecting to the data source
Run the VBScript programRun the VBScript program C:\Insertcustomers.vbs to insert the three customer records into the Customer table.Verify it worksIn SQL Query Analyzer, switch to the MyDatabase database, and then run this query:Alternate techniqueThe XML Bulk Load component is capable of:
REFERENCESSQLXML Books Online; topic: "Performing Bulk Load of XML Data"APPLIES TO
| Article Translations
|
Back to the top
