2012-05-04 159 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)... 
相關問題