Chapter 16. User-defined functions

After completing this chapter, you will be able to

  • Understand user-defined functions.

  • Create, alter, and delete functions.

  • Understand the difference between scalar and table-valued functions.

User-defined functions are similar to functions in other programming languages. Microsoft SQL Server 2012 allows you to create two types of functions: scalar and table-valued. These functions allow for a modular type of programming, where code and logic can be included inside the function. Other applications, routines, and database objects can then use the function. This approach also allows you to place standards and governance around how the code is developed and deployed.

Functions are T-SQL code that can accept parameters, ...

Get Microsoft® SQL Server® 2012 Step by Step 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.