April 2006
Intermediate to advanced
640 pages
16h 46m
English
The new APPLY table operator applies the right-hand table expression to every row of the left-hand table expression. Unlike a join, where there’s no importance to the order in which each of the table expressions is evaluated, APPLY must logically evaluate the left table expression first. This logical evaluation order of the inputs allows the right table expression to be correlated with the left one—something that was not possible prior to SQL Server 2005. The concept can probably be made clearer with an example.
Run the following code to create an inline table-valued function called fn_top_products:
IF OBJECT_ID('dbo.fn_top_products') IS NOT NULL DROP FUNCTION dbo.fn_top_products; GO CREATE FUNCTION dbo.fn_top_products (@supid AS INT, @catid ...Read now
Unlock full access