-
-
Save ashgadala/54335025b9f15e8f51b1b60c44d500af to your computer and use it in GitHub Desktop.
SQL HTML Encoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create function dbo.fn_HtmlEncode ( | |
| @Html as varchar ( max ) | |
| ) | |
| returns varchar ( max ) | |
| as | |
| /* | |
| select dbo.fn_HtmlEncode('<This is a T&st #>') | |
| */ | |
| begin | |
| declare @encoded as varchar ( max ) | |
| select @encoded = | |
| replace ( | |
| replace ( | |
| replace ( | |
| replace ( | |
| replace ( @Html, '&' , '&' ), | |
| '<' , '<' ), | |
| '>' , '>' ), | |
| ' ' , '+' ), | |
| '#' , '%23' ) | |
| return @encoded | |
| end | |
| go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment