• schleep (7/9/2014)


    So it turns out that in the 2 failing scenarios, the function is going through the full table before applying the WHERE clause, and failing on a row where first name or last name is null.

    In the working scenarios, the WHERE clause is applied first, and only one row is acted on.

    So am I to conclude that order does matter in the FROM clause?

    The execution plans for the working queries and the non-working queries are obviously different. You can't really jump to any conclusions without examining them.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden