SQL Server 2005/2008 supports 4 kinds of user defined functions:
- T-SQL scalar function
- T-SQL table-valued function
- CLR scalar function
- CLR table-valued function
What are the advantages of each type? What are the disadvantages? Can you give some examples of situations when each would be the "best" choice?
Finally, what is your favorite type, and why? I know that's a subjective question, but I think the answers can still be helpful for anyone new to UDFs (or new to a particular type).