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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s