Strip punctuation from MSSQL value

Soldato
Joined
18 Oct 2002
Posts
7,139
Location
Ironing
I'm trying to strip all punctuation out of a value in a MSSQl database so that I can compare it to a string that won't have any punctuation. For various reasons, I'm replacing the spaces as well with hyphens. Therefore, a given string of:

hello-there-everyone

should match a database value of

Hello There! Everyone!

Currently I've got
Code:
select * from table where REPLACE(field,' ','-') = @input
which takes care of the spaces/hyphens issue. Is there any way to strip out the punctuation without nesting lots of replace statements?
 
Back
Top Bottom