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 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.