T-SQL 101: 114 Selecting from Table-Valued Functions
In previous posts, we’ve seen how to query tables. Another type of object that you might need to query is a table-valued function.
Table-valued functions (TVFs) are predefined code i.e., somebody’s written the code, and they take parameters, but they return row set of data, much like a table.
So in the example above, I’m saying I want to declare a Cinema ID variable, and I’ve said let’s have Cinema 27. Then I’ve said I wanted to select from GetRecentOrders. It’s a TVF that takes two parameters: the Cinema ID, and the maximum number of orders to return. In the case, I’ve said that I want the last two orders for cinema 27.
2025-02-12