首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-02-20 
两字段求和写入第三个字段数据表结构如下:ABCDE------------------------123251111null123852121null45625

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

热点排行