begin
declare @pdctno char(7),@units char(3),@sunit int,@spanel int,@techno char(3)
declare scrapqty cursor for select pdctno, units,spanel,sunit from sheet1$
open scrapqty
fetch next from scrapqty into @pdctno,@units,@sunit,@spanel
while (@@fetch_status=0) begin
update proscjhb set procwip=procwip-@sunit where pdctno=@pdctno and techno='37' and units=@units
fetch next from scrapqty into @pdctno,@units,@sunit,@spanel
end
close scrapqty
deallocate scrapqty
end
declare @pdctno char(7),@units char(3),@sunit int,@spanel int,@techno char(3)
declare scrapqty cursor for select pdctno, units,spanel,sunit from sheet1$
open scrapqty
fetch next from scrapqty into @pdctno,@units,@sunit,@spanel
while (@@fetch_status=0) begin
update proscjhb set procwip=procwip-@sunit where pdctno=@pdctno and techno='37' and units=@units
fetch next from scrapqty into @pdctno,@units,@sunit,@spanel
end
close scrapqty
deallocate scrapqty
end
Update t2 Set t2.procwip=t2.procwip-t1.sunit From sheet1$ t1 Inner Join proscjhb t2 On t1.pdctno=t2.pdctno and t1.units=t2.units
Or
Update t2 Set t2.procwip=t2.procwip-t1.sunit From sheet1$ t1,proscjhb t2 Where t1.pdctno=t2.pdctno and t1.units=t2.units
and t2.techno='37'