views:

103

answers:

2

I would like to trim all special characters from a string in SQL. I've seen a bunch of people who use substring methods to remove a certain amount of characters, but in this case the length on each side of the string is unknown.

Anyone know how to do this?

Thanks,
Matt

+1  A: 

use replace function will help you

i mean to say when you want to remove special char replace this space' ' by using replace function

more about replace : http://technet.microsoft.com/en-us/library/ms186862.aspx

Pranay Rana
Replace isn't going to do a trim. What happens if I have something like... #!$#@$#!@Hello,World@!$><?..,@. In a case like that, I'd want to keep the ',' between 'Hello' and 'World'. Or, unlikely but still possible: #%$@#$Hello@!!%#$World@$#$ again, I want to keep the '@!!%#$' between 'Hello' and 'World'. Not quite going to work in that situation.
Matt
yes you are correct in that case but for this u need function like sub string with indexof.
Pranay Rana
A: 

In MS SQL, this will remove all plus signs:

SELECT REPLACE(theField, '+', '') FROM theTable

Is that the sort of thing you need?

egrunin