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

Announcements

No record found.

News and Announcements icon
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,897 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

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 518 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 431

#3
Adis Profile Picture

Adis 280 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans