title: SQL Comma separated string total count
body: <p>Schema :    </p>
  
  <pre><code>SubscriberId NewsletterIdCsv 
  ------------ --------------- 
  1     48,51,94     
  2     43,22
  3     33,11
  4     90,61 
  </code></pre>
  
  <p>I Need to get the count for each rows NewsletterIdCsv and then add all of them up to get a total count of all rows, for the basic row count I am doing the following:</p>
  
  <pre><code>SELECT newsletteridcsv, len(newsletteridcsv) - len(replace(newsletteridcsv, ',', '')) +1 IndividualCount
  FROM DBTABLE
  </code></pre>
  
  <p>This Gives me the Result :</p>
  
  <pre><code>NewsletterIdCsv IndividualCount
  ------------ --------------- 
  48,51,94     3
  43,22        2
  33,11        2
  90,61        2
  </code></pre>
  
  <p>How do I get the total count (In this example 9)?</p>
  
  <p>Note : This table has 5 Million records and I do not think using a temp table to Insert count and then finally going through the temp table rows to accumulate the count is an optimized way?
  Also I am totally against using cursors for efficiency issues !</p>
  
  <p>What's the best way to get the total count ?</p>