title: Count character pattern matches
body: <p>Is it possible, using pure <code>SQL</code> to count the number of <code>x</code>'s in the following strings?</p>
  
  <pre><code>708258761XXXXXXXX00A  
  708232761XXXXXXXXXXA
  </code></pre>
  
  <p>result when ran against the previous strings being</p>
  
  <pre><code>8
  10
  </code></pre>
  
  <p>I could easily do this in code, but I'm looking for a pure <code>T-SQL</code> method for doing this.</p>
  
  <p>The pattern will have varying numbers of <code>X</code>'s depending on the product I'm looking at. </p>
  
  <p>Put another way, What I'm looking for is a pure <code>SQL</code> way of counting the number of matches of a pattern.</p>
  
  <p>In the above example, the input pattern is <code>X</code>.  Using another example,  with a search pattern of <code>Ted</code> the following could return a value of <code>3</code>:</p>
  
  <blockquote>
    <p>Ted is Ted because Ted is awesome!</p>
  </blockquote>