Replace string with single quotes in it with another string SQL

Viewed 43

I have a value in a column (call the column c1) like below:

'there it is' is what she said

and I would like to replace it with:

'there it is plus two' is what she said

but having a hard time.

Using replace(c1
    , ''there it is' is what she said'
    , ''there it is plus two' is what she said')

Gives me "Incorrect syntax near there".

2 Answers

Quoting ' inside string '':

replace(c1
    , '''there it is'' is what she said'
    , '''there it is plus two'' is what she said')

You need to double single quotes in a string:

  replace(c1,
          '''there it is'' is what she said'
          '''there it is plus two'' is what she said'
         )
Related