• WolfgangE (1/14/2013)


    ....

    The disadvantages using the cross-apply-method I see are performance and maintenance:

    If the number of rows of the outer select increases the query will slow down as the apply-operator does the subselect for any outer row....

    Using a single CROSS APPLY valued to the row (i.e. with no table reference) to replace a single calculation referenced in two or more parts of the same query is quite likely to improve performance. Performance change, a very slight change in either direction, will scale in a linear manner with rowcount. It's not a subselect. It's most likely to show in the plan as a compute scalar.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]