• gcook 48147 (11/14/2014)


    I thought the SET required a subquery as that is how the examples were formatted that I found online. This is much simpler and more direct. Still learning, thanks!

    That's because SQL Server and it's Father, SyBase, both use T-SQL and is the only dialect of SQL that I personally know of that allows the use of a FROM clause in UPDATE, which works very much like a FROM clause in a SELECT. Of course, it has some of the same caveats so you need to pay attention to how you write the code but it's incredibly powerful and, as you noticed, is more simpler to write in most cases.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)