• mbova407 (9/6/2012)


    I guess I don't understand the question. How is using cross-apply with a where join any different then an inner join with the ON (or where) join

    SELECT

    tblA.S

    , tblA.R

    , tblB.S

    FROM

    #A tblA

    INNER JOIN

    #B tblB

    ON tblA.R = tblB.R

    This particular example isn't, which is why I wouldn't code this with a CROSS APPLY in production. But you can't JOIN to a table-value function (which is what CROSS APPLY was written for), and you can also put things like TOP X in a subquery with CROSS APPLY to limit the results from the right table, which you can't do in an INNER JOIN. Since this QotD is APPLY - 1, I'm guessing (and hoping) bitbucket has some more detailed examples of how to use CROSS APPLY coming in future questions.