add attribute and update value XML column sqlserver2008

poonnawermawl

New Member
I have seen several answers here on stackoverflow but I can not find what I'm looking for. I have checked this question and this one and some others pages but can't manage to get to a solution.This is my test data. Actually this code is inside an XML column in a table.\[code\]<product id=152><name>tractor</name><category weight=5600 invoice="A600"></product><product id=731><name>excavadora</name><category weight=12340 invoice="B300"></product>\[/code\]What I need is to update the previous XML doing two actions:
  • add new attribute on the category node
  • be able to update that new attribute value, tried modifying weight but can't get to do it
I think the solution should be using .modify and .value keywords in a query but don't know how.Im using SQL Server 2008 express. I have seen that a query can help to get an answer but I don't really have anything working. Thanks in advance
 
Back
Top