I know the thread is old, I was asked the same question, I did a test, the result as follows...
Records in FacCurrencyRate = 14264 while TestFunction returns 105 if executed independently.
SELECT F.*, x.CurrencyKey, x.CurrencyName
FROM (
SELECT CurrencyKey, CurrencyName FROM dbo.TestFunction()
) x
INNER JOIN [dbo].[FactCurrencyRate] F ON x.CurrencyKey = f.CurrencyKey;
The execution time is...
(14264 rows affected)
Table 'FactCurrencyRate'. Scan count 1, logical reads 75, physical reads 1, read-ahead reads 73, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'DimCurrency'. Scan count 1, logical reads 2, physical reads 1, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 31 ms, elapsed time = 749 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
If I use the suggested answer as follows...
select F.*, x.CurrencyKey, x.CurrencyName from [dbo].[FactCurrencyRate] F
cross apply dbo.TestFunction() x
The execution time and result count is...
(1497720 rows affected)
Table 'FactCurrencyRate'. Scan count 1, logical reads 75, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 1, logical reads 38110, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'DimCurrency'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 2106 ms, elapsed time = 43242 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
What I see here is that inner query brings out more correct set of results and execution time is much more efficient. Do correct me with better approach to accomplish the same!