0

I have tested the following statement.

UPDATE CharacterInfo 
SET ChaRating = floor((ChaRating + ChaOldRating)/2),
    ChaOldRating = ChaRating

And it seems this part (ChaOldRating = ChaRating) does set the value from the table before it's updated.

I don't want to leave this type of transaction to chance so I may need a clarification.

Does SQL Server update the row as a whole by default or is there a setting or statement that I may need to include in the stored procedure to make sure it does?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 2
    You know you could easily try it right? e.g. [dbfiddle](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=aba8cfc0a3690c60e8b33b16c2be5090) – Dale K Jun 25 '22 at 22:29
  • 2
    Somewhere in the spec it states that the right-hand side of the `=` always uses the old values, no matter which order you put them in. See also https://stackoverflow.com/questions/72683691/t-sql-order-of-columns-in-update and https://stackoverflow.com/questions/2203202/sql-update-order-of-evaluation – Charlieface Jun 26 '22 at 01:21

0 Answers0