title: T-Sql 2008 PatIndex error with 'AA' string
body: <p>I'm running this code on SQL2008 to remove non-aphanumerical characters from strings :</p>
  
  <pre><code>snip from my function stralpha:
  ...
  Set @KeepValues = '%[^a-z0-9]%'
  While PatIndex(@KeepValues, @Temp) &gt; 0
        Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '')
  Return @Temp
  ...
  </code></pre>
  
  <p>It has worked flawlessly, but now I've got at string with the part 'AA' in it : </p>
  
  <pre><code>SELECT dbo.stralpha('10AAV2');
  </code></pre>
  
  <p>which returns</p>
  
  <pre><code>10AV2
  </code></pre>
  
  <p>and I expected</p>
  
  <pre><code>10AAV2
  </code></pre>
  
  <p>I've tried with other repeating characters without problems - but can reproduce with aa as well.</p>
  
  <p>Does anyone have a hint troubleshoot?</p>