• komal145 (9/26/2012)


    ...

    UPDATE TableC

    SET step_desc= Tableb.StepDescription

    FROM #MAX_STEPMAX_STEP WITH (NOLOCK)

    JOIN TablebB WITH (NOLOCK) ON MAX_STEP.LoanNumber = b.LoanNumber

    and MAx_step.Step=b.step

    WHERE MAX_STEP.Row_ID = 2...

    This is an unrestricted update. Every row in tableC will be updated to the same value of step_desc, because TableC isn't referenced in the FROM list. Since it's a trivial matter to convert a SELECT...FROM into an UPDATE...FROM, why don't you write it and post it here? What you want is a query which will return step_desc from TableC and Tableb.StepDescription.

    “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