# Db2 – Remove single quotes from db2 column name

db2replacevarchar

I have following query which i am trying to execute against db2 database server

SELECT REPLACE('\'abc\'','\'','') FROM TN_DAY_PROCESS


I am expecting the output like abc without single quotes

from the abc text, I want to remove single quote. to do that, I tried the method shown above using REPLACE function in db2, but it is giving me following error

The character "\" following "ELECT REPLACE('\'abc" is not valid.. SQLCODE=-7, SQLSTATE=42601, DRIVER=3.66.46 SQL Code: -7, SQL State: 42601


Could somebody help me to figure out the solution to remove the single quotes from a string in db2 database.Thanks in advance for any help

While searching for an answer for this question, I found following method

SELECT REPLACE('''abc''','''',SPACE(0)) FROM TN_DAY_PROCESS


so, the way to specify single quote is to write it twice

As you found, you have to use '' to represent a single quote (').
You do not need to use the SPACE() function:
select replace(character_column, '''', '')

Note: Using SPACE() could actually create an issue as it returns VARCHAR(4000).