SQL Server: Using Table-valued Functions

In some cases, I like to use SQL Server Functions to encapsulate some of my SQL Server logic into reusable and maintainable components. Recently, I have found the use of Table-valued Functions to be extremely helpful.  With Table-valued functions, you can return multiple values, which is useful enough in itself, or even entire result sets.…