SQL Server UDF’s Considered Harmful
When you are analyzing a query plan in SQL Server, you need to be aware that time spent in User Defined Functions (UDFs) is not included in the query plan. This is a problem because programmers seem to like using UDFs to make their SQL more modular and because it is very easy to write UDFs that kill your performance. (See this article “UDF Performance Costs” for a simple example.)
A reliable way of measuring the costs of a UDF is to run your stored proc with and without the UDF, and to measure the time it takes to run it. I have seen 10x performance improvements between sprocs with UDFs and sprocs rewritten to remove UDFs.