T-SQL: User Defined Functions

Please see my other Database Development articles.

Creating reusable logic

As with Object-Oriented Programming (OOP) where it’s important to separate code used frequently into reusable modules, in T-SQL the same need exists.

In this example I demonstrate a user-defined function (UDF) that receive a string from which all pre-defined matching blocks of HTML are found and replace. The newly “cleansed” version is then sent back to the user.

user-defined-function-code

Once the UDF is called, none of the original HTML characters/tags remained.

user-defined-function-results

Leave a comment