cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

string function to replace all special ascii characters as ?

Former Member
0 Likes
8,116

I found this select syntax online but not able to make it work. Please help.

I have a table that have colName as TEXT column that has special ascii characters from 0 thru 31. I an trying to do a select for this colName that will replace all special characters as '?' What am I doing wrong in this select?

select REPLACE(**colName**, 
         SUBSTRING(**colName**, 
            PATINDEX('%[^a-zA-Z0-9 ]%', 
                  **colName** collate Latin1_General_BIN), 1), '?')
from table 
WHERE PATINDEX('%[^a-zA-Z0-9 ]%', **colName** collate Latin1_General_BIN) <> 0

Accepted Solutions (0)

Answers (1)

Answers (1)

MarkCulp
Participant
0 Likes

Take a look at my answer to a similar question.