Removing HTML Tags from a String in SQL Server

Views: 2.019
Reading Time: 4 minutes

Staff,
Good afternoon!

Today I will show you how to remove HTML tags from a string in SQL Server using only T-SQL. This function was very useful for me because there was a need to include a column in a report that was exported to XLS (Excel), but this column was the HTML description of the system-generated calls and in Excel that lot of HTML tags. It was really bad to read .. That's when I developed this function and introduce you.

FncRemove_HTML function source code:

Result:

FncRemove_Formatacao_Html function source code

Another way to remove HTML tags and formatting from strings is to use the fncRemove_Formatacao_Html function, which I demonstrate below.

Execution Result:

If you want to use this same function, but with the source code in C # and using CLR, for a much better performance, see the post SQL Server - How to Convert an HTML String to Text (Remove HTML Tags) Using CLR (C #).

A big hug, see you later!