HtmlEncode

Encodes a string that may contain HTML character entity references.

  • Free Function
  • SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017

Syntax:

SELECT SQLHTTP.net.HtmlEncode ( @String )

Arguments:

Name Type Description
@String nvarchar(MAX) Any character string, variable, or expression.

Return Type:

nvarchar(max)

Remarks:

See the following Wikipedia articles for a Character Entity References in HTML and Numeric Character Reference in HTML

Sample Usage:

Encoding a string to another string containing HTML character entity references:
SELECT SQLHTTP.net.HtmlEncode(‘I can now encode & decode an HTML string using SQL Server’)
———————————————————————————————–
I can now encode & decode an HTML string using SQL Server

See Also: