Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

SQL arithabort and nocount

$
0
0

I have one stored procedure . Its created by some one who worked before handover to me. Now my doubt is why they are used set arithabort on    
set nocount on  in this procedure and Can I remove it from here . Because if I am removing it I can see some data in two date range (1st of month to  end of month range). If these set arithabort on    
set nocount on  are there then some record are missing. Why , what is the behind it.

eg: 17-01-2014 one record is there if I am selecting  date from 17-01-2014  and To date 17-01-2014  // its fine

when i am selecting the date range  15-01-2014 and 18-01-2014 , then also I can see  17-01-2014 (same record) //its fine

when i am selecting the date range  15-01-2014 and 31-01-2014 , then alsoI can't see 17-01-2014 (same record) //its not fine , I want to see here. why ?  but after I removed set arithabort on    
set nocount on Its fine.  why ?  whats purpose we are using it these set arithabort on    
set nocount on here. 

I hope I can remove it. I thing it will make system slow or it will disturb other things. Kindly give me some solution.

I want to remove it.

create proc prodShortPostedByProductionDODi  (@DtFr datetime, @DtTo datetime) as           
set arithabort on    
set nocount on
 Select d.ItemCode,d.ItemName,d.ItemDetails,Type,DocCode,isnull(u.Ord,0) Ord, isnull(u.Short,0) Short,Customer_Code,Customer_Name,DocType,AdjustedUID,AdjustedTime ,e.FirstName        
 from B_Details d  with (nolock)          
 left join (select 'NOrd' Type,Dated,DocCode,ItemCode,isnull((QtyOrdered),0) Ord, ((QtyOrdered - Qty)) Short,DocType,Customer_Code,Customer_Name,AdjustedUID ,AdjustedTime        
   from Prod..ViwOrderListDetailsUnionHist        with (nolock)           
   where (Cancel is null or Cancel <> 'Y' ) and dated >=@DtFr and dated <=@DtTo and Qty <> QtyOrdered           
    Union all          
            select 'UOrd' Type,Dated,DocCode,ItemCode,isnull((QtyOrdered),0) Ord, ((QtyOrdered - Qty)) Short,DocType,Customer_Code,Customer_Name,AdjustedUID,AdjustedTime        
   from Prod..ViwUrgentOrderListDetailsUnionHist  with (nolock) where (Cancel is null or Cancel <> 'Y' )         
   and dated >=@DtFr and dated <=@DtTo and Qty <> QtyOrdered          
           )U on d.ItemCode=u.ItemCode          
left join User_Group_Id i on u.AdjustedUID=i.Ug_Code      
left join Employee      e on i.File_No    =e.File_No      
 Where Ord > 0 Or Short > 0           
 Order by d.ItemCode 

      

AK


Viewing all articles
Browse latest Browse all 8428

Trending Articles