2

I want to update single value of XML Node in SQl Server

Below is the table structure

enter image description here

XML Structure

<PayDetails>
  <Column Name="FG" DataType="float" Value="7241" />
  <Column Name="SKILL" DataType="float" Value="3" />
  <Column Name="PI" DataType="float" Value="87" />
  <Column Name="MD" DataType="float" Value="30" />
  <Column Name="LD" DataType="float" Value="4" />
  <Column Name="WEEKOFF_DAYS" DataType="float" Value="4" />   
  <Column Name="NETPAY" DataType="float" Value="5389" />    
</PayDetails>

I want to update value of FG from 7241 to 8000

1 Answer 1

5

You want to use replace value of...with keywords:

Try something like the following:

update tablename
set TransactionFieldDetails.modify(
'replace value of
(/PayDetails/Column[@Name="FG"]/@Value)[1]
with "8000"');
Sign up to request clarification or add additional context in comments.

1 Comment

Good to know, never heard of it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.