[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
Unofficial UNIT-e Forum • Using Table Valued Functions in SSMS
Page 1 of 1

Using Table Valued Functions in SSMS

Posted: Fri Mar 03, 2017 12:31 am
by robinwilson16
In case you have not come across table valued functions before, you can call them like a normal table.

Here is an example:
Table Valued Functions 1.PNG
Table Valued Functions 1.PNG (34.21 KiB) Viewed 2749 times
You can also join to table valued functions but must use CROSS APPLY and OUTER APPLY instead of INNER JOIN and LEFT JOIN.

This example shows how it works when cross applied:
Table Valued Functions 2.PNG
Table Valued Functions 2.PNG (121.38 KiB) Viewed 2749 times
Cross apply is required as the values passed into the function are not available using an INNER JOIN.
Aside from this CROSS APPLY and INNER JOIN are more or less identical and the query optimiser may switch an INNER JOIN to a CROSS APPLY anyway.