title: Using a CASE with the IN clause in T-SQL
body: <p>In My WHERE Clause I am using a CASE that will return all rows if parameter is blank or null. This works fine with single valuses. However not so well when using the IN clause. For example:</p>
  
  <p>This works very well, if there is not match then ALL records are returned!</p>
  
  <pre><code>AND 
  Name = CASE WHEN @Name_ != '' THEN @Name_ ELSE Name END
  AND
  </code></pre>
  
  <p>This works also, but there is no way to use the CASE expression, so if i do not provide some value i will not see any records:</p>
  
  <pre><code>AND
  Name IN (Select Names FROM Person Where Names like @Name_)
  AND 
  </code></pre>
  
  <p>Can I use a CASE with the 2nd example? So if there is not a match all Names will be returned?</p>