I have a SQL Server 2008 table with 50k rows, each with an XML fragment in a varchar column that looks like this:
<infoElems>
<infoElem id="1" Name="somename" money="3399.3984939" />
</infoElems>
I need to select out the varchar column, select out the money attribute, change it to an actual money type (3399.40 in my example), and then put the whole fragment back.
Can anyone point how to get me through this? I think I need to create an XML index of some sort? Confused.
Thanks.
The datatypes involved make this ugly, especially if the XML in your columns varies other than the price. Here is something that will work in SQL 2008. If you have to update lots of rows you will have to use this with a
CURSOR.Depending on your situation, it may be easier to just write an external script to do this. You could also look into using regex – see this post, but that could get really ugly.