Excel escaping quotes or apostrophes in cell values Excel escaping quotes or apostrophes in cell values sql sql

Excel escaping quotes or apostrophes in cell values


The best solution I have found is to use the following:

=SUBSTITUTE(A1, "'", "''")

This will replace all single quotes with two single quotes which, in T-SQL statements escapes the character and treats it as string data.


Similar to Roland:

=SUBSTITUTE(SUBSTITUTE(A1, "'", "\'"), ",", "\,")


Needed to do something similar so I could "escape" double quotes:

=CONCATENATE(CHAR(34),"hello",CHAR(34))

Result:

enter image description here