Chapter 2. User-Defined Functions
Itzik Ben-Gan and Dejan Sarka
User-defined functions (UDFs) are routines that perform calculations/computations and return a value—scalar (singular) or a table. Microsoft SQL Server 2008 allows you to develop UDFs using either T-SQL or a .NET language of your choice based on the common language runtime (CLR) integration in the product. You can incorporate UDFs in queries, computed columns, and constraints.
This chapter explores the types of UDFs that are supported by SQL Server: scalar-valued UDFs, which return a single value, and table-valued UDFs (inline and multiple-statement), which return a table. I’ll provide sample code for CLR UDFs in both C# and Microsoft Visual Basic.
Most of the .NET routines in this book ...
Get Inside Microsoft® SQL Server® 2008: T-SQL Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.