当前位置: 代码迷 >> Sql Server >> 两字段求和写入第三个字段,该怎么处理
  详细解决方案

两字段求和写入第三个字段,该怎么处理

热度:92   发布时间:2016-04-27 19:45:20.0
两字段求和写入第三个字段
数据表结构如下:
A                             B                             C                           D                           E
------------------------
123                         25                           11                         11                         null
123                         85                           21                         21                         null
456                         25                           8                           8                           null

我想将C、D相加并写入E,这样的SQL语句怎么写?

------解决方案--------------------
update 表名 set e=c+d
------解决方案--------------------
update table1 set e=convert(decimal(10,6),c+d) from table2 where table2.Barcode = table1.Barcode and table2.w= '123 '
  相关解决方案