Using STRING_ESCAPE

The STRING_ESCAPE function is a scalar function and escapes special characters in input text according to the given formatting rules. It returns input text with escaped characters. The function accepts the following two input arguments:

  • Text: This is an expression of any non-deprecated string data type.
  • Type: This argument must have the JSON value, since SQL Server 2016 currently supports only JSON as the formatting type.

The return type of the function is nvarchar(max). The STRING_ESCAPE function is a deterministic function; it always returns the same result for the same input parameters.

The data types text, ntext, and image are marked as deprecated features in SQL Server 2005. This means they can be removed in any ...

Get SQL Server 2017 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.