如何将此列添加到与其项目代码匹配的新表中?

时间:2017-11-28 12:08:15

标签: sql-server

insert into [CLOSING STOCK] 
select AOFC_IMS.Categories 
from AOFC_IMS 
where AOFC_IMS.[DISTRIBUTOR ITEM CODE]
           =[CLOSING STOCK].[DISTRIBUTOR ITEM CODE];

1 个答案:

答案 0 :(得分:0)

看起来你有一个名为Closing_Stock的表格,其中包含一个名为“我猜测,Categories的列,您要使用AOFC_IMS表格中的数据进行更新

UPDATE T1
SET T1.Categories = T2.Categories
FROM [CLOSING STOCK] T1
INNER JOIN [AOFC_IMS] T2 ON T1.[DISTRIBUTOR ITEM CODE]
                              = T2.[DISTRIBUTOR ITEM CODE];