CREATE TABLE Orders( CustomerID varchar(20), OrderDate varchar(25))
GO
DECLARE @docHandle int;
DECLARE @xmlDocument nvarchar(max);
SET @xmlDocument = N'<ROOT>
<Customers>
<Orders>
<CustomerID>XYZAA</CustomerID>
<OrderDate>2000-08-25T00:00:00</OrderDate>
</Orders>
<Orders>
<CustomerID>XYZAA</CustomerID>
<OrderDate>2000-10-03T00:00:00</OrderDate>
</Orders>
</Customers>
</ROOT>'
EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument
-- Use OPENXML to provide rowset consisting of customer data.
INSERT Orders
SELECT * FROM OPENXML(@docHandle, N'/ROOT/Customers/orders')
WITH (CustomerID nchar(5) 'CustomerID',
OrderDate nchar(25) 'OrderDate')
select * from Orders
-- Remove the internal representation of the XML document.
EXEC sp_xml_removedocument @docHandle
drop table Orders
CREATE TABLE Orders( CustomerID varchar(20), OrderDate varchar(25))
GO
DECLARE @docHandle int;
DECLARE @xmlDocument nvarchar(max);
SET @xmlDocument = N'<ROOT>
<Customers>
<Orders>
<CustomerID>XYZAA</CustomerID>
<OrderDate>2000-08-25T00:00:00</OrderDate>
</Orders>
<Orders>
<CustomerID>XYZAA</CustomerID>
<OrderDate>2000-10-03T00:00:00</OrderDate>
</Orders>
</Customers>
</ROOT>'
EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument
-- Use OPENXML to provide rowset consisting of customer data.
INSERT Orders
SELECT * FROM OPENXML(@docHandle, N'/ROOT/Customers/orders')
WITH (CustomerID nchar(5) 'CustomerID',
OrderDate nchar(25) 'OrderDate')
select * from Orders
-- Remove the internal representation of the XML document.
EXEC sp_xml_removedocument @docHandle
drop table Orders
一个大小写!!!!又是大小写,疯了!!有木有!!!搞定了