Skip to content
Advertisement

How can I replace a `’` in a string in SQL?

I have to replace special characters in SQL.

My problem is with ', because it is used for start and end of string in SQL.

I tried:

ID = REPLACE(ID, ''', '')
ID = REPLACE(ID, "'", "")

But both not worked. What should I do?

Advertisement

Answer

Either Use the char function and ascii code:

ID = REPLACE(ID, char(39), '')

or double down on the single quotes:

ID = REPLACE(ID, '''', '')
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement