How to generate XML file automatically when new record added in the SQL Server table?

Posted by Hemanth.Gottipati under C# on 10/8/2014 | Points: 10 | Views : 523 | Status : [Member] | Replies : 5
Hi,
My requirement is "Automatically generate XML File when new record added in the database table from code behind?"
Please give me suggestion how to generate XML automatically..




Responses

Posted by: Bandi on: 10/9/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link
http://www.codeproject.com/Articles/2599/Introduction-to-DataSets-and-working-with-XML-file

It may help you

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemanth.Gottipati on: 10/9/2014 [Member] Starter | Points: 25

Up
0
Down
Hi thanks for reply.
I don't want to create total dataset in to XML,I want only newly added record in the table into XML..

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/9/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
SELECT * FROM TableName where ID = @RecentlyAddedRowID FOR XML AUTO

The above query will generate XML format data and then store it into a .xml file in the code behind...

Refer the below link to generate XML form of data in SQL Server
http://www.codeproject.com/Articles/54584/Controlling-the-XML-output-when-using-the-FOR-XML

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemanth.Gottipati on: 10/9/2014 [Member] Starter | Points: 25

Up
0
Down
Is it possible to same thing done in the insert statement,because i am not fetching any records,after insert the record in the table
XML will be automatically generated is my requirement..

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/9/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
it is not possible with Single INSERT statement
follwo the below links
http://ask.sqlservercentral.com/questions/7158/output-sql-data-as-xml-and-export-to-xml-file.html
http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/09/28/how-to-convert-table-data-to-xml-and-xml-to-table.aspx



Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response