title: SQL: problem word count with len()
body: <p>I am trying to count words of text that is written in a column of table. Therefor I am using the following query.</p>
  
  <pre><code>SELECT LEN(ExtractedText) - 
  LEN(REPLACE(ExtractedText, ' ', '')) + 1 from EDDSDBO.Document where ID='100'.
  </code></pre>
  
  <p>I receive a wrong result that is much to high. 
  On the other hand, if I copy the text directly into the statement then it works, i.e.</p>
  
  <pre><code>SELECT LEN('blablabla text') - LEN(REPLACE('blablabla text', ' ', '')) + 1.
  </code></pre>
  
  <p>Now the datatype is <code>nvarchar(max)</code> since the text is very long. I have already tried to convert the column into <code>text</code> or <code>ntext</code> and to apply <code>datalength()</code> instead of <code>len()</code>. Nevertheless I obtain the same result that it does work as a string but does not work from a table.</p>