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

在A表中安插在B表中的值

2012-12-31 
在A表中插入在B表中的值在A表中插入在B表中的值例:A表id name notes12221323B表id name notes12312423结果

在A表中插入在B表中的值
在A表中插入在B表中的值

例:
A表
id name notes
1  2
2  2
1  3
2  3

B表
id name notes
1  2
3  1
2  4
2  3


结果 
id name notes
1  2
2  2
1  3
2  3
3  1
2  4
[解决办法]
在A表中安插在B表中的值

INSERT  #temp2_wastebook
         SELECT  a.shopid ,
                 a.deptid ,
                 a.goodsid ,
                 CONVERT(dec(10, 2), '0.00') ,
                 CONVERT(dec(10, 2), '0.00')
         FROM    #temp1_SaleCost a
         WHERE   NOT EXISTS ( SELECT 1
                              FROM   #temp2_wastebook b
                              WHERE  a.shopid = b.shopid
                                     AND a.deptid = b.deptid
                                     AND a.goodsid = b.goodsid )

热点排行