User-defined table functions

A user-defined table function (UDTF) is a function that you can invoke in a FROM clause of a SQL statement. It returns a table shape with columns that have names and types.

Unlike a user-defined function (which is a scalar function), a table function can return zero or more rows. You can invoke a table function with arguments, including literals and non-literal expressions that contain columns from other tables.

You can use table functions for such tasks as expanding data from one row into many rows, or to produce a summary by combining data from many rows. This can help you to create custom summaries in table form and to run unpivot operations such as combining the data from several related tables into a new combined table.

You can use a table function in a SQL clause almost anywhere you would use a table. You invoke the table function by using a form similar to TABLE (func-name (args)).