title: Check string in select statement using SQL Server 2008
body: <p>Here I need to check the string which is in the format '<code>a,c,e</code>'. This situation occurred when user select multiple option from check box and in the query I need to check it with the present column.</p>
  
  <p><strong>Example</strong>:</p>
  
  <p>Given string:  </p>
  
  <pre><code>'a,c,e'
  </code></pre>
  
  <p>Need to check the given string each word is present in the column <code>columnA</code> or not:</p>
  
  <pre><code>columnA    columnB
  -------------------
  a            1
  b            2
  c            3
  d            4
  e            5
  f            6
  g            7
  h            8
  </code></pre>
  
  <p>If <code>a,c,e</code> present in the column <code>columnA</code> it should retrieve with the <code>columnB</code>:</p>
  
  <p><strong>Expected Result</strong>:</p>
  
  <pre><code>columnA   columnB
  ------------------
  a            1
  c            3
  e            5
  </code></pre>
  
  <p>My try:</p>
  
  <pre><code>select columnA,columnB from 
  test where columnA ='a' 
  or columnA = 'c' 
  or columnA = 'e'
  </code></pre>
  
  <p>I don't feel! this is the optimize way to do so. And this is also not good for the dynamic query where the string values become changes concurrently. </p>