<p>We have some input data that sometimes appears with &amp;nbsp characters on the end.</p>

<p>The data comes in from the source system as varchar() and our attempts to cast as decimal fail b/c of these characters.</p>

<p>Ltrim and Rtrim don't remove the characters, so we're forced to do something like:</p>

<pre><code>UPDATE myTable
SET myColumn = replace(myColumn,char(160),'')
WHERE charindex(char(160),myColumn) &gt; 0
</code></pre>

<p>This works for the &amp;nbsp, but is there a good way to do this for any non-alphanumeric (or in this case numeric) characters?</p>

This page
has a sample of how you can remove non-alphanumeric chars:
```
```
-- Put something like this into a user function:
DECLARE @cString    VARCHAR(32)
DECLARE @nPos    INTEGER
SELECT  @cString = '90$%45623 *6%}~:@'
SELECT  @nPos = PATINDEX('%[^0-9]%', @cString)

WHILE @nPos > 0
BEGIN
SELECT @cString = STUFF(@cString, @nPos, 1, '')
SELECT  @nPos = PATINDEX('%[^0-9]%', @cString)
END

SELECT @cString
```
```