日期:2014-05-17 浏览次数:20475 次
--@XmlDocument是前台传入的xml 类型是 varchar(max)
EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument
insert into #XMLTable
SELECT * FROM OPENXML (@DocHandle, '/Roots/Base',2)
WITH (
f1 varchar(20),
f2 uniqueidentifier,
f3 float,
……
……
)
DECLARE @XmlDocumentHandle int
DECLARE @XmlDocument nvarchar(4000)
SET @XmlDocument = N'<ROOT>
<Customer>
<CustomerID>VINET</CustomerID>
<ContactName>Paul Henriot</ContactName>
<Order OrderID="10248" CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00">
<OrderDetail ProductID="11" Quantity="12"/>
<OrderDetail ProductID="42" Quantity="10"/>
</Order>
</Customer>
<Customer>
<CustomerID>LILAS</CustomerID>
<ContactName>Carlos Gonzlez</ContactName>
<Order OrderID="10283" CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00">