-- 2.先更新tb_Stock
update a
set a.GoodsNum=a.GoodsNum+b.[数量字段]
from tb_Stock a
inner join #t b on a.GoodsName=b.GoodsName and a.GoodsPrice=b.GoodsPrice
-- 3.后插入tb_Stock
insert into tb_Stock
(GoodsID,UserID,CompanyName,DepotName,GoodsName,GoodsNum,GoodsUnit,
GoodsTime,GoodsSpec,GoodsPrice,SellPrice,Remark,NeedPay,HasPay,sort)
select [字段列表]
from #t a
where not exists(select 1 from tb_Stock b
where a.GoodsName=b.GoodsName and a.GoodsPrice=b.GoodsPrice)