title: T-SQL: CASE statement in WHERE?
body: <p>I have the following WHERE clause in my SQL query currently:</p>
  
  <pre><code>WHERE c.Town LIKE '%' + @Town + '%'
  </code></pre>
  
  <p>What I want do is make the first '%' optional - so if the user has selected to just filter by records that just start with the given text, the WHERE would be</p>
  
  <pre><code>WHERE c.Town LIKE @Town + '%'
  </code></pre>
  
  <p>I assumed the simplest way to do this would be CASE statements, but I'm having no joy as it seems the syntax is incorrect. Can I get any pointers? Here's the CASE statement I was trying:</p>
  
  <pre><code>WHERE c.Town LIKE (CASE WHEN @FilterOptions = 1 THEN '%' ELSE '') + @Town + '%'
  </code></pre>