chapter 14 1 chapter 14 storing and retrieving xml in sql server 2000 november 6, 2001 sook-kyo kwon
TRANSCRIPT
11 Chapter 14Chapter 14
Chapter 14 Chapter 14 Storing and Retrieving XML in Storing and Retrieving XML in
SQL Server 2000SQL Server 2000
NovemberNovember 6, 20016, 2001
Sook-Kyo KwonSook-Kyo Kwon
22 Chapter 14Chapter 14
ContentsContents
• Objectives
• Retrieving XML : FOR XML
• Storing XML : OPENXML
• XML Bulk Load
• Summary
33 Chapter 14Chapter 14
ObjectivesObjectives
• Eliminate to write complex ASP(Active Server Pages) applications
• SQL Server 2000 includes XML supports
– Allow to view the entire relational database as XML
• Server side features
– FOR XML : retrieve data from SQL ser as an XML
– OPENXML : shred XML documents and store them in relational tables
– XML Bulk Load : bulk load from an XML document into SQL
– XML Views : provide an XML view of relational data
– Xpath query support : query the XML view
– XML Updategrams : update data in relational tables using XML views
Enhance query performance and system performance in updating
44 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (1)Retrieving XML from SQL server 2000: FOR XML (1)
DescriptionDescription
• SQL server 2000 provides enhanced query support
• We can request the result of a SELECT statement be returned as an XML
• To retrieve the result of SELECT statement as XML, we must specify the
FOR XML clause in the SELECT statement.
Three ModesThree Modes
• RAW Mode : produces attribute-centric XML with flat structure
• AUTO Mode : produces XML where the hierarchy of elements in the
resulting XML is determined by the order of columns in the SELECT
statements. have limited control over the shape of XML produced.
• EXPLICIT Mode : allows the user to have total control over the shape of the
resulting XML.
55 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (2)Retrieving XML from SQL server 2000: FOR XML (2)
FOR XML : General SyntaxFOR XML : General Syntax
• XMLDATA is specified : XML-Data schema for the resulting XML is returned
as a part of the result.
• ELEMENTS is specified : an element-centric documents is to be returned in
which the column values are returned as sub-elements. Only applies in
AUTO mode.
• BINARY Base64 is specified: any binary data returned is represented in
base64-encoded format. This should be specified in RAW and EXPILICT.
The AUTO mode returns data as a URL reference by default.
FOR XML xml_mode [,XMLDATA], [,ELEMENTS], [BINARY BASE64]
66 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (3)Retrieving XML from SQL server 2000: FOR XML (3)
The RAW Mode(1)The RAW Mode(1)
• If the RAW mode is specified, each row in the rowset returned by the SELECT statement is transformed into an element with generic tag <row> and the columns as attribute.
• Query (1)
SELECT C.CustomerID, O.OrderID, OorderDateFROM Customers C, Order O WHERE C.CustomerID = O.CustomerIDORDER BY C.CustoerID, O.OrderIDFOR XML RAW
<row CustomerID=“ALFKI” OrderID=“10643” OrderDate=“1997-08-25T00:00:00”/><row CustomerID=“ALFKI” OrderID=“10692” OrderDate=“1997-10-03-T00:00:00”/><row CustomerID=“ALFKI” OrderID=“10702” OrderDate=“1997-10-13-T00:00:00”/>
77 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (4)Retrieving XML from SQL server 2000: FOR XML (4)
The RAW Mode (2)The RAW Mode (2)
• Request XDR schema for the resulting XML
• Query (2)
SELECT C.CustomerID, O.OrderID, OorderDateFROM Customers C, Order O WHERE C.CustomerID = O.CustomerIDORDER BY C.CustoerID, O.OrderIDFOR XML RAW, XMLDATAXMLDATA
<Schema name=“Schema1” xmlns=“urn:schemas-micrsoft-com:xml-data” xmlns:dt=“urn:schemas-microsoft-com:datatypes”> <ElementType name=“row” content=“empty” model=“close”> <AttributeType name=“CustomerID” dt:type=“string”/> <AttributeType name=“OrderID” dt:type=“i4”/> <AttributeType name=“OrderDate” dt:type=“dateTime”/> <attribute type=“CustomerID”/> <attribute type=“OrderID”/> <attribute type=“OrderDate”/> </ElementType></Schema><row xmlns=“x-schema:#Schma1” CustomerID=ALFKI” OrderID=“10643” OrderDate=“1997-08-25T00:00:00”/><row xmlns=“x-schema:#Schma1” CustomerID=ALFKI” OrderID=“10692” OrderDate=“1997-10-03T00:00:00”/><row xmlns=“x-schema:#Schma1” CustomerID=ALFKI” OrderID=“10643” OrderDate=“1997-10-13T00:00:00”/>
88 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (5)Retrieving XML from SQL server 2000: FOR XML (5)
The AUTO Mode (1)The AUTO Mode (1)
• The query specified with AUTO mode generates hierarchical XML
• Query (3)
SELECT Customers.CustomerID, ContactName,Order ID, OrderDate
FROM Customers , Orders WHERE Customers.CustomerID = Orders.CustomerIDORDER BY Customers.CustoerID, Orders.OrderIDFOR XML AUTO
<Customers CustomerID=“ALFKI” ContactName=“Maria Andres”> <Orders OrderID=“10643” OrderDate=“1997-08-25T00:00:00”/> <Orders OrderID=“10692” OrderDate=“1997-10-03T00:00:00”/> <Orders OrderID=“10702” OrderDate=“1997-10-13T00:00:00”/><Orders ……</Customers><Customers CustomerID=“ANATR” ContactName=“Ana Trujillo”> <Orders OrderID=“10308” OrderDate=“1996-09-18T00:00:00”/> <Orders OrderID=“10625” OrderDate=“1997-08-08T00:00:00”/> ……</Customers> ……
99 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (6)Retrieving XML from SQL server 2000: FOR XML (6)
The AUTO Mode (2)The AUTO Mode (2)
• The ELEMENTS option: each column name maps to sub-elements with text only contents.
• Query (4)
SELECT Customers.CustomerID, ContactName,Order ID, OrderDate
FROM Customers , Orders WHERE Customers.CustomerID = Orders.CustomerIDORDER BY Customers.CustoerID, Orders.OrderIDFOR XML AUTO, ELEMENTSELEMENTS
<Customers> <CustomersID>ALFKI</CustomerID> <ContactName>Maria Anders</ContactName> <Orders> <OrderID>10643</OrderID> <OrderDate>1997-08-25T00:00:00</OrderDate> </Orders> …..</Customers><Customers> <CustomersID>ANATR</CustomerID> <ContactName>Ana Trujillo</ContactName> <Orders> <OrderID>10308</OrderID> <OrderDate>1996-09-18T00:00:00</OrderDate> </Orders> ……</Customers>
1010 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (7)Retrieving XML from SQL server 2000: FOR XML (7) The EXPLICIT Mode (1)The EXPLICIT Mode (1)
• Allows you total control over the resulting XML.
• We can decide the shape of the resulting XML .
1. Specifying Column Aliases
In SELECT clauses, the column aliases should be specified. Information in the column aliases is used to generate the XML hierarchy.
SELECT 1 as Tag,NULL as Parent,Customers.CustomerID as [Cust!1!CustID]Customers.ContactName as [Cust!1!Contact]
FROM CustomersORDER BY [Cust!1CustID]FOR XML EXPLICIT
<Cust CustID=“ALFKI” Contact=Maria Andres”/> <Cust CustID=“ANATR” Contact=“Ana Trujillo”
1111 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (8)Retrieving XML from SQL server 2000: FOR XML (8) The EXPLICIT Mode (2)The EXPLICIT Mode (2)
2. Specifying The Metadata Column
– Tag and Parent columns are providing parent-child relationship information between elements in XML that is generated by the query.
– Tag column provides a numeric tag number of the element
– Parent column is used to define which element is the parent of this element
SELECT 1 as Tag,NULL as Parent,Customers.CustomerID as [Cust!1!CustID]Customers.ContactName as [Cust!1!Contact]
FROM CustomersORDER BY [Cust!1CustID]FOR XML EXPLICIT
1212 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (9)Retrieving XML from SQL server 2000: FOR XML (9) The EXPLICIT Mode (3)The EXPLICIT Mode (3)
3. Specifying The Directive in the Column Alias (1)
– Identify certain attributes in the query as being of type id,idref, or idrefs.
– Request the resulting XML be an element-centric document
– Wrap data in the XML in CDATA section
– Specify how to deal with characters in the data returned by SQL server that are special in XML
SELECT 1 as Tag,NULL as Parent,Customers.CustomerID as [Cust!1!CustID!id]Customers.ContactName as [Cust!1!Contact]
FROM CustomersORDER BY [Cust!1CustID!id]FOR XML EXPLICIT,XMLDATAXMLDATA
<Schema name=“Schema2” xmlns=“urn:schemas-micrsoft-com:xml-data” xmlns:dt=“urn:schemas-microsoft-com:datatypes”> <ElementType name=“Cust” content=“mixed” model=“open”> <AttributeType name=“CustID” dt:type=“id”/> <AttributeType name=“Contact” dt:type=“string”/> <attribute type=“CustID”/> <attribute type=“OrderDate”/> </ElementType></Schema><Cust xmlns=“x-schema:#Schma2” CustomerID=“ALFKI” Contact=“Maria Anders”/><Cust xmlns=“x-schema:#Schma2” CustomerID=“ANATR” Contact=“Ana Trujillo”/>…
1313 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (10)Retrieving XML from SQL server 2000: FOR XML (10) The EXPLICIT Mode (4)The EXPLICIT Mode (4)
3. Specifying The Directive in the Column Alias (2)
SELECT 1 as Tag,NULL as Parent,Customers.CustomerID as [Cust!1!CustID!element]Customers.ContactName as [Cust!1!Contact!element]
FROM CustomersORDER BY [Cust!1CustID!element]FOR XML EXPLICIT
<Cust> <CustID>ALFKI</CustID> <Contact>Maria Anders</Contact></Cust><Cust> <CustID>ANATR</CustID> <Contact>Ana Trujillo</Contact></Cust>…
SELECT 1 as Tag,NULL as Parent,Customers.CustomerID as [Cust!1!CustID]Customers.ContactName as [Cust!1!Contact!element]
FROM CustomersORDER BY [Cust!1CustID]FOR XML EXPLICIT
<Cust CustID=“ALFKI”> <Contact>Maria Anders</Contact></Cust><Cust CustID=“ANATR”> <Contact>Ana Trujillo</Contact></Cust>…
1414 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (11)Retrieving XML from SQL server 2000: FOR XML (11) The EXPLICIT Mode (5)The EXPLICIT Mode (5)
Generating XML from the Rowset(Universal Table)
SELECT 1 as Tag,NULL as Parent,Customers.CustomerID as [Cust!1!CustID]Customers.ContactName as [Cust!1!Contact]
FROM CustomersORDER BY [Cust!1CustID]FOR XML EXPLICIT
Tag Parent Cust!1!CustID Cust!1!Contact---------------------------------------------------------------------------------------------1 NULL “ALFKI” “Maria Andrers”1 NULL “ANATR” “Ana Trujillo”1 NULL “ANTON” “Antonio Moreno”
<Cust CustID=“ALFKI” Contact=“Maria Anders”/> <Cust CustID=“ANATR” Contact=“Ana Trujillo”/>> …
1515 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (12)Retrieving XML from SQL server 2000: FOR XML (12) The EXPLICIT Mode (6)The EXPLICIT Mode (6)
Hierarchy Generation
SELECT 1 as Tag,NULL as Parent,Customers.CustomerID as [Custtomer!1!CustomerID]NULL as [Order!2!OrderID]
FROM Customers
Tag Parent Customer!1!CustomerID Order!2!OrderID---------------------------------------------------------------------------------------------1 NULL ALFKI NULL1 NULL ANATR NULL
Tag Parent Customer!1!CustomerID Order!2!OrderID---------------------------------------------------------------------------------------------2 1 ALFKI 106432 1 ALFKI 106922 1 ANATR 103082 1 ANATR 10625
SELECT 2,1,Customers.CustomerIDOrders.OrderID
FROM Customers,OrdersWHERE Customers.CustomerID = Orders.CustomerID
1616 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (13)Retrieving XML from SQL server 2000: FOR XML (13) The EXPLICIT Mode (7)The EXPLICIT Mode (7)
Hierarchy Generation – Union All
SELECT 1 as Tag,NULL as Parent,Customers.CustomerID as [Custtomer!1!CustomerID]NULL as [Order!2!OrderID]
FROM CustomersUNION ALLUNION ALLSELECT 2,
1,Customers.CustomerIDOrders.OrderID
FROM Customers,OrdersWHERE Customers.CustomerID = Orders.CustomerIDORDER BY [Customer!1!CustomerID], [Order!2!OrderID]FOR XML EXLICITFOR XML EXLICIT
Rowset (Universal Table)Rowset (Universal Table)
Tag Parent Customer!1!CustomerID Order!2!OrderID-----------------------------------------------------------------------------1 NULL ALFKI NULL2 1 ALFKI 106432 1 ALFKI 106922 1 ALFKI …1 NULL ANATR NULL2 1 ANATR 103082 1 ANATR 106252 1 ANATR …..
1717 Chapter 14Chapter 14
Retrieving XML from SQL server 2000: FOR XML (14)Retrieving XML from SQL server 2000: FOR XML (14) The EXPLICIT Mode (8)The EXPLICIT Mode (8)
Hierarchy Generation – Union All:Resulting XML
<Customer CustomerID=“ALFKI” > <Orders OrderID=“10643” /> <Orders OrderID=“10692” /> ……</Customers><Customers CustomerID=“ANATR” > <Orders OrderID=“10308” /> <Orders OrderID=“10625” /> ……</Customers> ……
1818 Chapter 14Chapter 14
Storing XML in SQL server 2000: OPENXML (1)Storing XML in SQL server 2000: OPENXML (1)
DescriptionDescription
• OPENXML function in SQL Server 2000 is a rowset provider.
• Create a rowset from the XML daat and pass it to the INSERT, UPDATE, or
DELETE statement.
• The OPENXML feature in SQL server 2000 allows you to store data from
XML documents or document fragments in database tables.
STEPSSTEPS
• Create an in-memory DOM representation of the XML document
• Use OPENXML to create a rowset view of this XML. As part of OPENXML,
specify an Xpath expression to retrieve the desired elements.
• Pass this rowset to INSERT, UPDATE, and DELETE statemens to update
the database.
• Destroy the in-memory DOM representation of the XML document
1919 Chapter 14Chapter 14
Storing XML in SQL server 2000: OPENXML (2)Storing XML in SQL server 2000: OPENXML (2)
OPENXML : General SyntaxOPENXML : General Syntax
• DocHandle: XML handle returned by sp_xml_preparedocument
• XpathPattern: identifies the nodes in the XML document that will be mapped to the
rowset generated. (ex.: Xpath pattern /root/Order/OrderDetail identifies the
<OrderDetail> child element nodes of the <Order> child element node of the
<root>element.
• Flags:specifies how the attributes/sub-elements in the XML document map to the
columns of the rowset being generated. (1 for attribute-centric, 2 for element-centric, 3
for mixed)
• WITH Clause: used to provide the description of the rowset schema to generate.
– Don’t specify, Specify an existing table name, Specify the rowset schema yourself
OPENXML (DocHandle int,XPathPattern nvarchar,[Flags byte])
[WITH (RowsetSchema | Tab;eName]
2020 Chapter 14Chapter 14
Storing XML in SQL server 2000: OPENXML (3)Storing XML in SQL server 2000: OPENXML (3)
EXAMPLEEXAMPLE– CustOrder Table
CustomerOrder(oid varchar(10), orderdate datetime, requireddate datetime)
– XML Document
<root> <Customer cid= “Cust1” name=“Bob” city=“Seatle”> <Order oid=“Ord1” empid=“1” orderdate=“10/1/2000”
requireddate=“11/1/2000” note=“ship 2nd day UPS” />
<Order oid=“Ord2” empid=“1” orderdate=“10/2/2000” requireddate=“12/1/2000” /> </Customer> <Customer cid= “C2” name=“John” city=“NewYork”> <Order oid=“Ord3” empid=“2” orderdate=“9/1/2000”
requireddate=“10/1/2000” <Order oid=“Ord4” empid=“3” orderdate=“9/2/2000” requireddate=“10/2/2000” /> </Customer></root>
SELECT *FROM OPENXML (@hdoc, ‘/root/Customer/Order’)
WITH CustOder
The document handle and the table name are passed to
OPENXML
2121 Chapter 14Chapter 14
Storing XML in SQL server 2000: OPENXML (4)Storing XML in SQL server 2000: OPENXML (4)
oid orderdate requireddate--------------------------------------------------------------------------------------Ord1 2000-10-01 00:00:00.000 2000-11-01 00:00:00.000Ord2 2000-10-02 00:00:00.000 2000-12-01 00:00:00.000Ord3 2000-09-01 00:00:00.000 2000-10-01 00:00:00.000Ord4 2000-09-02 00:00:00.000 2000-10-02 00:00:00.000
INSERT INTO CustOrderINSERT INTO CustOrderSELECT *FROM OPENXML (@hdoc, ‘/root/Customer/Order’)
WITH CustOder
The resulting three-column rowset returned by the SELECT statement
UPDATE CustOrderUPDATE CustOrderSET requireddate =
(SELECT requireddateFROM OPENXML (@hdoc, ‘/root/Customer/Order’)
WITH CustOrderWHERE oid = ‘Oid1’)WHERE oid = ‘Oid1’)
SELECT *FROM OPENXML (@hdoc, ‘/root/Customer/Order’)
WITH (oidWITH (oid varchar(20)varchar(20) orderdateorderdate datetimedatetime
requireddaterequireddate datetime)datetime)
Specify rowset schemaSpecify rowset schema
2222 Chapter 14Chapter 14
Storing XML in SQL server 2000: OPENXML (5)Storing XML in SQL server 2000: OPENXML (5)
Attribut-Centric and Element-centric Mapping
DECLARE @hdoc intDECLARE @doc varchar(1000)SET @doc=‘<root> <Customer cid= “Cust1” name=“Bob” city=“Seatle”> <Order oid=“Ord1” empid=“1” >
<orderdate>10/1/2000/</orderdate><requireddate>11/1/2000</requireddate> note=“ship 2nd day UPS”
</Order> <Order oid=“Ord2” empid=“1” >
<orderdate>10/2/2000/</orderdate><requireddate>12/1/2000</requireddate>
</Customer> <Customer cid= “C2” name=“John” city=“NewYork”> <Order oid=“Ord3” empid=“2” > <orderdate>9/1/2000/</orderdate> <requireddate>10/1/2000</requireddate> </Order> <Order oid=“Ord4” empid=“3” > <orderdate>9/2/2000/</orderdate> <requireddate>10/21/2000</requireddate> </Order> </Customer></root>
EXEC sp_xml_prepareddocument @hdoc OUTPUT, @doc
EXEC sp_xml_removeddocument @hdoc
SELECT *FROM FROM OPENXML (@hdoc, ‘/root/Customer/Order’,3)OPENXML (@hdoc, ‘/root/Customer/Order’,3)
WITH (oidWITH (oid varchar(20)varchar(20) orderdateorderdate datetimedatetime
requireddaterequireddate datetime)datetime)
2323 Chapter 14Chapter 14
Storing XML in SQL server 2000: OPENXML (6)Storing XML in SQL server 2000: OPENXML (6)
OrdID OrdDate OrdReqDate--------------------------------------------------------------------------------------Ord1 2000-10-01 00:00:00.000 2000-11-01 00:00:00.000Ord2 2000-10-02 00:00:00.000 2000-12-01 00:00:00.000Ord3 2000-09-01 00:00:00.000 2000-10-01 00:00:00.000Ord4 2000-09-02 00:00:00.000 2000-10-02 00:00:00.000
Additional Mapping Information : genral syntax
ColumnName datatpe [AdditonalMapping] ColumnName datatpe [AdditonalMapping]
SELECT *FROM OPENXML (@hdoc, ‘/root/Customer/Order’ ,1)
WITH (OrdIDWITH (OrdID varchar(20) ‘@oid’,varchar(20) ‘@oid’, OrdDateOrdDate datetime ‘@orderdate’,datetime ‘@orderdate’,
OrdReqDateOrdReqDate datetime ‘@requireddate’)datetime ‘@requireddate’)
2424 Chapter 14Chapter 14
Storing XML in SQL server 2000: OPENXML (7)Storing XML in SQL server 2000: OPENXML (7)
oid CustName UniqueIDVal NodeName NodeSibling------------------------------------------------------------------------------------------Ord1 Bob 6 Order NULLOrd2 Bob 12 Order 6Ord3 John 21 Order NULLOrd4 John 26 Order 21
Metaproperty Attributes
- @mp:id, @mp:localname, @mp:namespaceuri, @mp:prefix, @mp:prev, @mp:xmltext
SELECT *FROM OPENXML (@hdoc, ‘/root/Customer/Order’ ,3)
WITH ( oidWITH ( oid varchar(20) varchar(20) CustNameCustName varchar(10) varchar(10) ‘../@name’, ‘../@name’,
UniqueIDVal int UniqueIDVal int ‘mp@:id’, ‘mp@:id’,NodeNmaeNodeNmae varchar(10) varchar(10) ‘mp@localname’, ‘mp@localname’,NodeSibiling varchar(10) NodeSibiling varchar(10) ‘mp:prev’) ‘mp:prev’)
2525 Chapter 14Chapter 14
Bulk Loading XML (1)Bulk Loading XML (1)
DescriptionDescription
• Loading large amounts of XML onto the database
• Use the XML Bulk Load object from code via Bulk Load object model. We
need to pass it two pieces of information:
– The Mapping schema: The mapping XDR schema must be provided.
– The XML document that you want to bulk load
PropertiesProperties
• Specify whether we want to execute Bulk Load in transaction mode or not.
• Specify if we want to tables created before loading the data.
• Checking any contraint violations (primary key or foreign key)
• Specify error logging file/message generated during execution
• Execute, ConnectionCommand, ConnectionString, KeepNulls, KeepIdentity,
CheckConstraints, ForceTableLock, XMLFragment, Transaction,
TempFilePath, ErrorLogFile, SchemaGen, SGDropTables, SGUseID
2626 Chapter 14Chapter 14
Bulk Loading XML (2)Bulk Loading XML (2)
EXAMPLEEXAMPLE
CREATE TABLE Customer ( Customer ID int primary key, CompanyName varchar(20) NOT NULL, City varchar(20) default ‘Seattle’)GoCREATE TABLE CustOrder ( OrderID varchar(10) primary key CustomerID int foreign key refrences Customer (CustomerID), OrderDate datetime default ‘2000-01-01’)Go
<Customers CustomerID=“1111” CompanyName=“Sean Chai” City=“NY” OrdeList=“Ord1 Ord2” /><Customers CustomerID=“1112” CompanyName=“Don’t Know” City=“LA” OrdeList=“Ord3 Ord4” /><Order OrderID=“ord1” CustomerID=“1111” OrderDate=“1999-01-01” /><Order OrderID=“ord2” CustomerID=“1111” OrderDate=“1999-02-01” /><Order OrderID=“ord3” CustomerID=“1112” OrderDate=“1999-03-01” /><Order OrderID=“ord4” CustomerID=“1112” OrderDate=“1999-04-01” />
XML Data
XML Data is bulk loaded in these tables
2727 Chapter 14Chapter 14
Bulk Loading XML (3)Bulk Loading XML (3)
EXAMPLE – Executing Bulk Load : Visual Basic codeEXAMPLE – Executing Bulk Load : Visual Basic code
Set objBL = CreateObject(“SQLXMLBulkLoad.SQLXMLBulkLoad”)ObjBL.ConnectionString = “proiver=SQLOLEDB.1;data “ & _ “source=server;database=database;uid=sa;pwd=“objBL.ErrorLogFile = “c:\error.log”objBL.CheckConstraints=TrueobjBL.XMLFragment=TrueobjBL.Execute “c:\XMLView.xml”, “c:\XMLData.xml”Set objBL1=Nothing
1. Create a SQLXMLBulkLOad object(objBL)2. Set various properties3. Execute method is called. Execute method takes two parameters:
the schema file name and XML data file name.