Understanding User-Defined Functions

When you start creating complex T-SQL programs or use T-SQL in another programming language such as Visual Basic, you will probably use the same calculations over and over again. Most languages give you the ability to define your own subroutines or functions to be reused in multiple places in your application. T-SQL is no different when it comes to defining your own functions. These user-defined functions provide you with the ability to create any type of function you might need. SQL Server 2000 supports three types of UDFs:

  • Scalar functions

  • Inline single table value functions

  • Multi-statement table value functions

User-defined functions can be created to return either a scalar (single value) or a table (either ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition 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.