CHAPTER 16

image

Functions

Functions were introduced in SQL Server 2000 and made an immediate impact. Functions allow you to wrap up pieces of code you use all the time into a nice, compact, reusable package. In this chapter, we’ll find out what types of function SQL Server allows us to create, why functions are useful, and how we can improve our code with functions. We’ll also see some of the system functions SQL Server provides. By the end of this chapter, we’ll know all about scalar functions, and we’ll be ready to talk about table-valued functions (TVFs) in Chapter 17. We’ll be half-functional!

Function Types

Broadly speaking, there are two types ...

Get Introducing SQL Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.