title: Speed Up Text Search Query Large Data Set
body: <p>Hi I'm hoping someone has a tip for me.  I have a query below which filters detail field in the #TempLogins table.  The details field is a text field which contains many types of text strings, some containing urls that have parts like "ResultID=5" which is what is contained in the ResultIDSearch and ResultSetIDSearch fields.  The records with entries like "ResultID=5" are the ones I'm trying to filter for.</p>
  
  <p>The problem I have is that the query takes way too long to run.  The TempLogin table has around 200 K records and the TempSearch table has around 80 K records.</p>
  
  <p>Any tips on how to rewrite or speed this query up would be greatly appreciated. </p>
  
  <pre><code>enter code here: select * from #TempLogins a where exists
                        (select 1 from #TempSearch t1 where 
                                   a.detail like '%' + t1.ResultIDSearch + '%'
                                   or 
                                   a.detail like '%' + t1.ResultSetIDSearch + '%')
  </code></pre>