I want to remove all non-letter, non-number characters in a string. An example string would be: How#can*I^make this@work?
I would like it to look like HowcanImakethiswork
I need to do this for a whole field. Any ideas?
create function CharOnly(@TargetString varchar(500))
declare @NewString varchar(50)
declare @Counter int
set @NewString = ''
set @Counter = 0
while @Counter < len(@TargetString)
set @Counter = @Counter + 1
if ASCII(UPPER(substring(@TargetString, @Counter, 1))) between 65 and 90 set @NewString = @NewString + substring(@TargetString, @Counter, 1)
Then use it in your select statement like this:
select dbo.CharOnly('How#can*I^make this@work?')