web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Which part should be corrected to make Query performance faster in SSMS?

(1) ShareShare
ReportReport
Posted on by 9
select                                                                         
               ivc.InvoiceNumber                                                          
            , ivc.BillComplContrHdrNumber                                              
            , ivc.SummaryInvoiceNumber                                                 
            , ivc.IndivOrChgCmplContrNumber                                            
            , ivc.CustAcctSiteCode                                                     
           ,  hd.CustAcctSiteCode                                                      
            from                                                                          
                earth_ad_CustInvoice as ivc join earth_ad_CustInvoiceHeader hd             
               on (                                                                       
                  ivc.SummaryInvoiceNumber != ''                                          
                  and ivc.SummaryInvoiceNumber = hd.SummaryInvoiceNumber                   
               )                                                                          
               or (                                                                       
                 ivc.SummaryInvoiceNumber = ''                                        
                  and ivc.InvoiceNumber = hd.InvoiceNumber                                 
                )                                                                         
            where                                                                         
                ivc.ChrgComplInvNumModifier in ('000', 'Z')                            
                and ivc.BillComplContrHdrNumber not like N'H%'                           
                and ivc.InvoiceProgress in ('Z', '6')                                
               and ivc.ConfirmFormDisplayFlag = 'N'                                    
                and ivc.InvoiceEditedFlag in ('1', '2')                              
                and ivc.InvalidFlag = '0'                                               
                and ivc.EmergencyStopFlag != '1'                                       
                and ivc.InpSlipCorrectionFlag = 'N'                                    
                and ivc.DATAAREAID = 'b002'                                               
                and not exists (                                                           
                    select                                                                 
                      ChannelClassification                                                
                    from                                                                   
                      earth_md_Corporation co join CustTable ct                            
                        on ct.earth_md_CorporationCode = co.CorporationCode                
                        and ct.DATAAREAID = 'b002'                                        
                    join earth_ad_SalesTradingContracts sa                                 
                        on sa.CustAcctSiteId = ct.AccountNum                               
                        and sa.SalesTradingContractNumber = ivc.IndivOrChgCmplContrNumber  
                        and sa.DATAAREAID = 'b002'                                        
                    where                                                                  
                      co.ChannelClassification =2                                     
                )                                                                          
                and not exists (                                                           
                    select                                                                 
                      SummaryInvoiceNumber                                                 
                    from                                                                   
                      earth_ad_CustSummaryInvoice csi                                      
                    where                                                                  
                     csi.SummaryInvoiceNumber = ivc.SummaryInvoiceNumber                  
                      and csi.ChrgComplWaitingFlg = 'Y'                                
                      and csi.DATAAREAID = 'b002'                                         
                )                                            

 

 
I have the same question (0)
  • Martin Dráb Profile Picture
    238,272 Most Valuable Professional on at
    Please read my reply in your previous thread How to make a Query performance faster as below query is taking too long time instead of creating more threads on the same topic.
  • b_radlyjames Profile Picture
    3,157 on at
    Any time you use 'like' it will slow things down.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 357 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans