title: Strip special characters in SQL without loop?
body: <p>Is there a way to strip special characters (leaving just alphanumeric) from a string/field in SQL server without a loop / custom function?</p>
  
  <p>So far, the best i've come up with is:</p>
  
  <pre><code>Create Function [dbo].[strip_special](@Temp VarChar(1000))
  Returns VarChar(1000)
  AS
  Begin
      While PatIndex('%[^a-z0-9]%', @Temp) &gt; 0
          Set @Temp = Stuff(@Temp, PatIndex('%[^a-z0-9]%', @Temp), 1, '')
      Return @TEmp
  End
  </code></pre>
  
  <p>On some servers I don't have the privileges to cread user defined functions so i'd like to be able to achieve the same result without. 
  I also have concerns over the efficiency/performance of the loop (although I guess even a built-in function/method would probably itself use a loop).</p>
  
  <p>Thanks</p>