title: Trying to achieve SQL "WHERE IN" functionality through "LIKE"
body: <p>This is a pretty common topic, but I've yet to be able to find an answer that works.</p>
  
  <p>I am trying to match entries in a table to a list I supply from a webpage.</p>
  
  <p>Here is what works:</p>
  
  <pre><code>WHERE '40663953,40663951,40663949,40663781' 
  LIKE '%' + cast(IDNumber as varchar(8)) + '%'
  </code></pre>
  
  <p>(I tried it with the reversed order, with the column IDNumber going first, but didn't get any results)</p>
  
  <p>or </p>
  
  <pre><code>WHERE cast(IDNumber as varchar(8)) in 
  ('40663953','40663951','40663949','40663781')
  </code></pre>
  
  <p>Here's what doesn't work:</p>
  
  <pre><code> WHERE  @IDNumberList LIKE '%' + cast(IDNumber as varchar(8)) + '%'
  </code></pre>
  
  <p>and</p>
  
  <pre><code> WHERE cast(IDNumber as varchar(8)) in (@IDNumberList)
  </code></pre>
  
  <p>I've tried using dynamic <code>sql</code> but it's not working for various reasons. Any ideas that could save me?</p>