xml文件導(dǎo)入sql數(shù)據(jù)庫 請問如何將一個XML文件中的內(nèi)容導(dǎo)入到數(shù)據(jù)庫不同的表中?
請問如何將一個XML文件中的內(nèi)容導(dǎo)入到數(shù)據(jù)庫不同的表中?----導(dǎo)入 xml 文件DECLARE @idoc intDECLARE @doc varchar(1000)--sample XML doc
請問如何將一個XML文件中的內(nèi)容導(dǎo)入到數(shù)據(jù)庫不同的表中?
----導(dǎo)入 xml 文件DECLARE @idoc intDECLARE @doc varchar(1000)--sample XML documentSET @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 bluewhite 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
xml文件導(dǎo)入sql數(shù)據(jù)庫?
bcp bulk insert 都可以 bcp 實用工具可以在 Microsoft SQL Server 實例和用戶指定格式的數(shù)據(jù)文件間大容量復(fù)制數(shù)據(jù)。使用 bcp 實用工具可以將大量新行導(dǎo)入 SQL Server 表,或?qū)⒈頂?shù)據(jù)導(dǎo)入數(shù)據(jù)文件。 語法舉例: bcp AdventureWorks.Sales.Currency2 in Currency.dat -T -f Currency.xml 程序里面最好用這個。如果手動,管理器中導(dǎo)入就可以,用.net程序也可以,xml可以作為一個數(shù)據(jù)源操作。