简体   繁体   中英

Replace string with single quotes in it with another string SQL

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".

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'
         )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM