使用SQL Server更新XML列的单个XML节点值

时间:2021-01-08 17:03:59

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

我想更新SQl Server中XML节点的单个值

Below is the table structure

下面是表结构

使用SQL Server更新XML列的单个XML节点值

XML Structure

XML结构

<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

我想把FG的值从7241更新到8000

1 个解决方案

#1


4  

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"');

#1


4  

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"');