String cleaning with TSQL
There have been some posts on cleaning text with TSQL,
Remove
all non-numeric characters from a string and extract-only-numbers-from-a-string
Here is my take on it. The nice thing is that you just
specify the valid characters in the like pattern to select those that you
want.return.
declare @string
varchar(200)
set @string
= 'this
$%^^&is%^& s2342om23&&({}e c76l232e+_+a#n/
c][#o''d#e'
select cast(cast((select substring(@string,n,1)
from
num
where n <= len(@string)
and substring(@string,n,1) like '[a-z ]' for xml path('')) as xml)as varchar(max))
-