Adding data to a XML data type in SQL Server



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



CREATE TABLE T (i int, log xml);


Where the log structure is something like:



<auditLog>
<entry action="Created" description="New item created" value="banana" />
<entry action="Deleted" description="Deleted item" value="apple" />
</auditLog>


I am trying to figure out if/how it is possible to add another entry to this xml file. I have found lots of functions to add nodes to the current entries but not how to make a new entry. I assume that there must be a simple way of doing this but I cant seem to find it.


Any pointers would be very welcome.


No comments:

Post a Comment