KnllBst
KnllBst

Reputation: 121

how to remove ' from string

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

Answers (2)

Jigar
Jigar

Reputation: 3261

Use Replace function to replace that character (').

replace(name,"'","");

Link 1

Link 2

Upvotes: 0

Gordon Linoff
Gordon Linoff

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

Related Questions