Skip to Main Content
Learn T-SQL Querying
book

Learn T-SQL Querying

by Pedro Lopes, Pam Lahoud
May 2019
Intermediate to advanced content levelIntermediate to advanced
484 pages
11h 23m
English
Packt Publishing
Content preview from Learn T-SQL Querying

Deconstructing table-valued functions

A User-Defined Function (UDF) is like a stored procedure in that it is a block of T-SQL statements saved as an object, but it differs in that it does not generate a result set, it returns a value of a specified type. A scalar UDF is a function that returns a single value, a Table-Valued Function (TVF) is a function that returns a table.

There are two types of TVFs in SQL Server:

  • Multi-statement TVFs (MSTVFs): MSTVFs declare a return table type, populates the table, then returns the table at the end of the function
  • Inline TVFs: You can think of an inline TVF like a view that takes a parameter, the body of the function is a single query and the return value is the result of that query

The following is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn T-SQL Querying - Second Edition

Learn T-SQL Querying - Second Edition

Pedro Lopes, Pam Lahoud
SQL Server T-SQL Recipes, Fourth Edition

SQL Server T-SQL Recipes, Fourth Edition

Jason Brimhall, Jonathan Gennick, Wayne Sheffield

Publisher Resources

ISBN: 9781789348811Supplemental Content