• Ninja's_RGR'us (11/27/2008)


    I meant this by quirky update :

    Update table set @Var = UpdatedColumn = @Var + WhateverIttakesToEvalutateThisVariable

    This must be used with a index hint on a temp table to be sure that nothing goes wrong...

    That's a way to make a running total... the case statement here would be quite interesting though ;-P.

    Oohh, that one.

    You know that this "trick" is neither documented nor supported, do you?

    (Clarification: "UPDATE ... SET @var = column = expression" is documented and supported, but the effects of the same variable in the expression are not - and given the official intent of an UPDATE statement, the results people currently get in 99% of all cases could be considered a bug).


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/