Reputation: 121
Im trying to use the TRIM command in SQL to Remove special characters from a string. thing is i cant seem to figure out how to remove the ' character like how when people use it in their surname.
e.g O'Reilly
in order to remove a character i have to quote it, but how can put in quotes or identify the character ' when it is used for quoting.
Upvotes: 0
Views: 118
Reputation: 3261
Use Replace function to replace that character (').
replace(name,"'","");
Upvotes: 0
Reputation: 1269603
You want to use replace()
and not trim()
. Then, the escaping of single quotes requires doubling it, plus the outer single quotes. So:
replace(name, '''', '')
---------------^^ escaped single quote
--------------^--^ string delimiter for the single quote character
Upvotes: 4