I am new to SQL, and I am trying to filter and change values inside a column that contains an XML document for a purchased order. Here is an example of what an XML document looks like and what I'm looking for.
<TenderLines> <TenderLineItem> <tenderTypeId>S0001-00000001</tenderTypeId> .. .. </TenderLineItem> <TenderLines>
I have 6000+ lines, and not all of them have the same TypeId tender. I want to filter the values in tenderTypeId that have "S0001-00000001" and change them to "2"
So far this is what I came 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 request is successful, but nothing is changing, and I was wondering if any of you could read this and maybe give me some advice.
Thanks for your time, best regards, Valdi.
PS I am using Microsoft SQL Server 2008 R2 - Express Edition
source share