2012-05-04 141 views
0

我有一个格式类似于下面的XML数据:只要SQL Server 2005中的XML数据导入

<Orders> 
    <Order> 
    <OrderID>1</OrderID> 
    <OrderInfo>mydetails</OrderInfo> 
     <orderlines> 
     <orderline> 
      <orderlineref>1.1</orderlineref> 
      <product>myproduct</product> 
      <quantity>5</quantity> 
     </orderline> 
     <orderline> 
      <orderlineref>1.2</orderlineref> 
      <product>myproduct1</product> 
      <quantity>7</quantity> 
     </orderline> 
     </orderlines> 
    </Order> 
</Orders> 

我想使用BCP(或任何其他方法真的)导入到SQL Server 2005的这个它的运行速度非常快。

我该如何着手为这种类型的XML创建格式文件? 还是我在错误的方向看。

到目前为止,我设法导入这些数据的唯一方法是使用openrowset,但它需要太长时间。

任何建议吗?

+0

[XML文档的批量导入和导出的例子(SQL Server)](http://msdn.microsoft.com/en-us/library/ms191184.aspx ) –

回答

0

你为什么不将它转换为xml,如:

declare @x xml 

set @x='<Orders> 
    ... 
</Orders>' 

declare @x nvarchar(max) 

set @x='<Orders> 
    ... 
</Orders>' 

然后:

cast (@x as xml)... 
相关问题