title: sql like query slow if using declare parameter but fast if not
body: <p>SQL 2008:
  This is slow (takes 1 1/2 minutes):</p>
  
  <pre>
  declare @p1 varchar(50)
  set @p1 = '976j%'
  select * from invsearch_query where comparepnfwd like @p1
  </pre>
  
  <p>This takes less than a second:</p>
  
  <pre>
  select * from invsearch_query where comparepnfwd like '976j%'
  </pre>
  
  <p>Why???</p>