How to escape character from a string

To escape character from a string uses sql replace function or string_escape function for sql server.

Syntax

REPLACE ( string_expression , string_pattern , string_replacement )

STRING_ESCAPE( text , type )


Examples

SELECT REPLACE('123456789','6789','');

SELECT REPLACE('123456789','6789','111');

SELECT REPLACE('123456789','6789',1);

SELECT REPLACE('123456789','123','AAA');

SELECT REPLACE('ABC','B','X');

SELECT STRING_ESCAPE('"aaa", bbb', 'json');

SELECT STRING_ESCAPE('\a\b\c', 'json');

SELECT STRING_ESCAPE('ab cdef', 'json');