Go to this page, scroll down to Figure 21 and copy the code there. In SQL Management Studio, open a query window, change to the database where you want to install the function, paste the code you copied and click the Execute button. This will create the function in your database. You need to do this only once.