title: Need Help Speeding Up a SQL Server Query
body: <p>I have a stored procedure that creates quite a few temp tables in memory. I have the following query which takes an extremely long time to run (7 minutes).</p>
  
  <pre><code>select 
    a.DEPT,
    a.DIV,
    a.PART,
  convert(datetime,convert(varchar(2),datepart("mm",a.Release_Date))+'/1/'+ convert(varchar(4),datepart("yyyy",a.Release_Date)),101) as rptng_mnth
  from @tmpReportData3 a
  where not exists
  (select distinct DEPT,DIV,PART from @tmpReportData4 b
  where a.DEPT = b.DEPT and a.DIV = b.DIV and a.PART = b.PART)
  order by rptng_mnth
  </code></pre>
  
  <p>Is there a way to speed this up?</p>