Adding data to a XML data type in SQL Server -


I have a table that contains an XML data type that acts like an audit log.

  Create table T (i int, log xml);  

Where the log structure is something similar:

  & lt; Auditlog & gt; & Lt; Entry action = "created" description = "new item created" value = "banana" /> & Lt; Entry action = "deleted" description = "deleted item" value = "apple" /> & Lt; / AuditLog & gt;  

I am trying to figure out how to add another entry in this XML file. I have got a lot of work to add to nodes in existing entries but not how to do the new entry. I think there should be a simple way of doing this, but I am unable to find it.

Any indication will be very welcome.

You are probably confused with the fact that your XML node is named entry What you are doing is putting a new node in your XML data. You can use this:

  UPDATE T SET [log] .modify ('enter & lt; entry action = "added" details = "new entry added" value = "orange 


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -