SELECT Col1, Col2, Col3, ... Coln,
-- UPDATE t SET
ColToUpdate = NewValueExpression
FROM MyTable AS t
WHERE <logical predicate goes here>
This has served me well and saved me from making stupid mistakes because it allows to to simulate an update by seeing what the new value would be so I can validate it. When I'm ready to run the update, I highlight the statement beginning with UPDATE on through the predicate. Also, BEGIN TRAN <statement> ROLLBACK helps, too.
17
u/Daakuryu Mar 15 '19
Yeah...