Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can i insert multiple records from xml data into sql database

xml data is:

XML
<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>


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..
Posted
Comments
Kuthuparakkal 27-Aug-12 8:11am    
What's the front end ? or do you want to accomplish this with just TSQL ?

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.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900