create proc usp_Calc as set nocount on;if exists(select 1 from purchase as p join sales as s on p.cBatchcode=s.cBatchcode join crapped as c on p.cBatchcode=c.cBatchcode --where p.cBatchcode=@cBatchcode group by p.cBatchcode having sum(iBigQty-iSalesBigQty-iCraBigQty)=0 and sum(iCenterQty-iSalesCenterQty-iCraCenterQty)=0 and sum(iMinQty-iSalesMinQty-iCrappedMinQty)=0 ) begin print 'Now .' end else begin raiserror('Can''t calculate now,cause some products left.',16,1); return; end
create proc usp_Calc
as
set nocount on;if exists(select 1
from purchase as p
join sales as s on p.cBatchcode=s.cBatchcode
join crapped as c on p.cBatchcode=c.cBatchcode
--where p.cBatchcode=@cBatchcode
group by p.cBatchcode
having sum(iBigQty-iSalesBigQty-iCraBigQty)=0
and sum(iCenterQty-iSalesCenterQty-iCraCenterQty)=0
and sum(iMinQty-iSalesMinQty-iCrappedMinQty)=0
)
begin
print 'Now .'
end
else
begin
raiserror('Can''t calculate now,cause some products left.',16,1);
return;
end