Skip to main content

Notifications

Announcements

No record found.

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'                                         
                )                                            

 

 
  • b_radlyjames Profile Picture
    b_radlyjames 3,081 on at
    Which part should be corrected to make Query performance faster in SSMS?
    Any time you use 'like' it will slow things down.
  • Martin Dráb Profile Picture
    Martin Dráb 230,414 Most Valuable Professional on at
    Which part should be corrected to make Query performance faster in SSMS?
    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.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,684 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,414 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans