A function is a section of code that is used to perform an isolated assignment. Once it has performed its assignment, the function can be accessed to present its result(s).
In Transact-SQL, a function is considered an object. After creating the function object, it becomes part of a database. You can then execute it when necessary.
View Complete Post