从XML插入多个记录到sql DB [英] insert multiple records from XML to sql DB
本文介绍了从XML插入多个记录到sql DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将多个记录从xml数据插入到sql数据库中
xml数据为:
How can i insert multiple records from xml data into sql database
xml data is:
<DataSource>
<Table1>
<Id>23</Id>
<name>xxx</name>
</Table1>
<Table1>
<Id>24</Id>
<name>yyy</name>
</Table1>
<Table1>
<Id>25</Id>
<name>zzz</name>
</Table1>
</DataSource>
在我的数据库表中,我已经有一个类似Id = 1,2,.... 22的记录.
现在,我想在数据库中插入第23、24、25条记录.
in my DataBase table already i have a records like this Id=1,2,....22.
Now i want to insert 23,24,25 th records in to my DB.
can any one help me to do this..
推荐答案
您可以使用SQL本身读取和写入xml.
从这些链接获取帮助
http://blog .sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/ [ http://blog .sqlauthority.com/2009/02/12/sql-server-simple-example-of-creating-xml-file-using-t-sql/ [
You can read and write xml using SQL itself.
Get the help from these links
http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/[^]
http://blog.sqlauthority.com/2009/02/12/sql-server-simple-example-of-creating-xml-file-using-t-sql/[^]
However, check whether the Id column is an Identity column or not. If it is an auto generated column then you need not send the value via xml.
引用
读取XML的简单示例使用T-SQL的文件 [
Refer
Simple Example of Reading XML File Using T-SQL[^]
检查这些链接
http://stackoverflow.com/questions/3989395/convert-xml-to-table- sql-server [ ^ ]
http://kennyshu.blogspot.in/2007/12/convert-xml-file-to-table-in-sql-2005.html [
Check these links
http://stackoverflow.com/questions/3989395/convert-xml-to-table-sql-server[^]
http://kennyshu.blogspot.in/2007/12/convert-xml-file-to-table-in-sql-2005.html[^]
这篇关于从XML插入多个记录到sql DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文