title: SQL Count distinct values within the field
body: <p>I have this weird scenario (at least it is for me) where I have a table (actually a result set, but I want to make it simpler) that looks like the following:</p>
  
  <pre><code>ID  |  Actions
  ------------------
  1   |  10,12,15
  2   |  11,12,13
  3   |  15  
  4   |  14,15,16,17
  </code></pre>
  
  <p>And I want to count the different actions in the all the table. In this case, I want the result to be 8 (just counting 10, 11, ...., 17; and ignoring the repeated values).</p>
  
  <p>In case it matters, I am using MS SQL 2008.</p>
  
  <p>If it makes it any easier, the Actions were previously on XML that looks like</p>
  
  <pre><code>&lt;root&gt;
    &lt;actions&gt;10,12,15&lt;/actions&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I doubt it makes it easier, but somebody might comeback with an xml function that I am not aware and just makes everything easier.</p>
  
  <p>Let me know if there's something else I should say.</p>