标题:(求助)怎么导入XML文件到SQL
只看楼主
sd4331177
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-9-26
 问题点数:0 回复次数:1 
(求助)怎么导入XML文件到SQL
想导入XML文件到书库里,路径是D:\桌面\PRE-ALERT.xml,我该怎么做?
谢谢!
搜索更多相关主题的帖子: SQL XML 文件 
2008-09-26 13:01
卜酷塔
Rank: 7Rank: 7Rank: 7
来 自:魅力青岛
等 级:禁止访问
威 望:39
帖 子:2569
专家分:0
注 册:2004-6-12
得分:0 
DECLARE @idoc int
DECLARE @doc varchar(1000)
--sample XML document
SET @doc ='
<root>
<Customer cid= "C1" name="Janine" city="Issaquah">
<Order oid="O1" date="1/20/1996" amount="3.5" />
<Order oid="O2" date="4/30/1997" amount="13.4">Customer was very satisfied
</Order>
</Customer>
<Customer cid="C2" name="Ursula" city="Oelde" >
<Order oid="O3" date="7/14/1999" amount="100" note="Wrap it blue
white red">
<Urgency>Important</Urgency>
Happy Customer.
</Order>
<Order oid="O4" date="1/20/1996" amount="10000"/>
</Customer>
</root>
'
-- Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc

-- Execute a SELECT statement using OPENXML rowset provider.
SELECT *
FROM OPENXML (@idoc, '/root/Customer/Order', 1)
WITH (oid char(5),
amount float,
comment ntext 'text()')
EXEC sp_xml_removedocument @idoc
网上找来的,楼主试试吧,应该可以。

觉得为时已晚的时候,恰恰是最早的时候。

2008-09-26 14:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-235309-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.096734 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved