if exists (select * from tempdb..sysobjects where type='u' and name='forcurrentsyz') drop table tempdb..forcurrentsyz go select cwhcode,cinvcode,sum(iquantity) as iquantity into tempdb..forcurrentsyz from ( select cwhcode,cinvcode,iaInquantity as iquantity from ia_subsidiary where cvoutype='3 ...