Escapes special characters in texts and returns text (nvarchar(max)
) with escaped characters.
Parameters:
text. is a nvarchar
expression representing the string that should be escaped.
type. Escaping rules that will be applied. Currently the only supported value is 'json'
.
SELECT STRING_ESCAPE('\ /
\\ " ', 'json') -- returns '\\\t\/\n\\\\\t\"\t'
List of characters that will be escaped:
Special character Encoded sequence
-------------------------------------
Quotation mark (") \"
Reverse solidus (\) \\
Solidus (/) \/
Backspace \b
Form feed \f
New line \n
Carriage return \r
Horizontal tab \t
Control character Encoded sequence
------------------------------------
CHAR(0) \u0000
CHAR(1) \u0001
... ...
CHAR(31) \u001f