Here is the XML I have in my Table Field
<CtcConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Ctc>3</Ctc>
<SalaryComponent>
<SalaryComponentConfiguration>
<Name>Basic</Name>
<DisplayOrder>0</DisplayOrder>
<Value>5634655</Value>
</SalaryComponentConfiguration>
<SalaryComponentConfiguration>
<Name>HR</Name>
<DisplayOrder>0</DisplayOrder>
<Value>1234</Value>
</SalaryComponentConfiguration>
<SalaryComponentConfiguration>
<Name>medical</Name>
<DisplayOrder>0</DisplayOrder>
<Value>0</Value>
</SalaryComponentConfiguration>
</SalaryComponent>
</CtcConfiguration>
I want the update the existing node(DisplayOrder)
value by multiplying it with n times.
This is what I get so far to update a node value:
DECLARE @NodeName VARCHAR(100)=N'Basic';
DECLARE @NewValue INT=3;
UPDATE payroll.pays
SET CtcConfiguration.modify(
N'replace value of (/CtcConfiguration
/SalaryComponent
/SalaryComponentConfiguration[(Name/text())[1]=sql:variable("@NodeName")]
/Value/text())[1]
with sql:variable("@NewValue")');