Show all Hide all

This function removes all occurrences of a specified HTML tag from a supplied string. Typical usage could for example be to remove unwanted or dangerous tags from the HTML body of an email message before displaying said message on an HTML page.

Use the additional bit-arguments to specify whether the tag should be treated as self closing, or when not self closing, whether the tags inner-HTML should be removed together with the tag.

The special case of a null-string will give a return value of null.

Type: Scalar function
Area of use: General use

Return value: nvarchar(max)

The processed string.


@String mandatory nvarchar(max)
The string to process.
@Tag mandatory nvarchar(300)
The type of tag to remove, i.e. specify 'br' to remove all "<br>"-tags etc.
@IsSelfClosing mandatory bit
Specifies whether the tag should be considered self closing or not.
@StripInnerHtml mandatory bit
Used together with tags that are not self closing to specify whether any inner html should be stripped away together with the tag itself.