I'm fairly new to SQL and I'm trying to filter and change the values inside of column that holds an XML document for a purchased order. Here's an example of what the XML document looks like and what I'm searching for.
<TenderLines>
<TenderLineItem>
<tenderTypeId>S0001-00000001</tenderTypeId>
..
..
</TenderLineItem>
<TenderLines>
I've got 6000+ rows and not all of them have the same tenderTypeId. I want to filter out the values in tenderTypeId that have 'S0001-00000001' and change them to '2'
So far this is what I've come up with.
USE LSPOS80
DECLARE @replacement as varchar(50)
DECLARE @redundant as varchar(50)
SET @replacement = '2'
SET @redundant = 'S0001-00000001'
Update dbo.POSISTRANSACTIONTABLE
SET TRANSACTIONXML.modify
('replace value of(/RetailTransaction/TenderLines/TenderLineItem/tenderTypeId/@redundant) [1] with sql:variable("@replacement")')
The query is executed successfully but nothing changes and I was wondering if any of you could read over this and possibly give me tips.
Thanks for your time, with best regards, Valdi.
P.S. I'm using Microsoft SQL Server 2008 R2 - Express Edition