title: SQL String: Counting Words inside a String
body: <p>I searched through many of the questions here but all I found with decent answer is for different language like Javascript etc.</p>
  
  <p>I have a simple task in SQL that I can't seem to find a simple way to do.
  I just need to count the number of "words" inside a SQL string (a sentence). You can see why "words" is in quotes in my examples. The "words" are delimited by white space.</p>
  
  <p>Sample sentences:</p>
  
  <pre><code>1. I am not your father.
  2. Where are your brother,sister,mother?
  3. Where are your brother, sister and mother?
  4. Who are     you?
  </code></pre>
  
  <p>Desired answer:</p>
  
  <pre><code>1. 5
  2. 4
  3. 7
  4. 3
  </code></pre>
  
  <p>As you can see, I need to count the "words" disregarding the symbols (I have to treat them as part of the word). So in sample no. 2:
  <code>(1)Where (2)are (3)your (4)brother,sister,mother? = 4</code></p>
  
  <p>I can handle the multiple whitespaces by doing a replace like this:<br/>
  <code>REPLACE(string, '  ', ' ') -&gt; 2 whitespaces to 1
  REPLACE(string, '   ', ' ') -&gt; 3 whitespaces to 1 and so on..</code> </p>
  
  <p>What SQL function can I use to do this? I use SQL Server 2012 but needs a function that works in SQL Server 2008 as well.</p>