日期:2014-05-18  浏览次数:20532 次

两字段求和写入第三个字段
数据表结构如下:
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 '