Inline Functions

Inline functions are also quite powerful. They provide a “parameterized view” type of functionality; something many of us have been requesting of Microsoft for years. An inline table-valued function has no body, so there's no BEGIN…END requirement with it. It consists only of a SELECT query, happily ensconced in a RETURN statement. Because the SELECT defines what type of table is actually returned, the RETURNS clause of an inline function simply lists TABLE as the return type, with no accompanying table definition. This differs from regular table-valued functions in which the entire table definition must be included in the RETURNS clause.

Here's an example that demonstrates an inline function (Listing 10-3):

Listing 10-3. A basic ...

Get Guru's Guide to SQL Server™ Stored Procedures, XML, and HTML, The 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.