Escapes special characters in texts and returns text with escaped characters. STRING_ESCAPE is a deterministic function.
Transact-SQL Syntax Conventions
STRING_ESCAPE( text , type )
text
Is a nvarcharexpression expression representing the object that should be escaped.
type
Escaping rules that will be applied. Currently the value supported is 'json'.
nvarchar(max) text with escaped special and control characters. Currently STRING_ESCAPE can only escape JSON special characters shown in the following tables.
| Special character | Encoded sequence |
|---|---|
| Quotation mark (") | \" |
| Reverse solidus (\) | \| |
| Solidus (/) | \/ |
| Backspace | |
| Form feed | |
| New line | |
| Carriage return | |
| Horizontal tab |
| Control character | Encoded sequence |
|---|