For SQL Server, What is the proper way to update a table?
Study the following:


BEGIN TRANSACTION, ROLLBACK TRANSACTION, COMMIT TRANSACTION

Also read Paul Randall's A SQL Server DBA myth a day: (26/30) nested transactions are real
Also read XACT_ABORT

@@ROWCOUNT
IF ...ELSE
GOTO
@@TRANCOUNT
More advanced topics, optional until they're not:

SET TRANSACTION ISOLATION LEVEL
Gail Shaw's intro to deadlocks



Then re-read this general technique:


At the start of the code, GOTO :TheEnd

partial protection against a few "only run part of the code, not all the code" mistakes

At the end of the code, GOTO :TheBeginning

partial protection against a few "only run part of the code, not all the code" mistakes

SET XACT_ABORT ON and start a transaction
Code a single DML statement with appropriate WHERE and JOIN clauses
Code a check how many rows it affected; if it's not exactly as many rows as you expected, roll back the transaction.

repeat the above coding as many times as you have statements

default to rolling back the transaction.

code the COMMIT only after you're sure it's all correct.
run the COMMIT only after getting a cup of coffee, in case you have a moment of fridge horror

Check to verify transaction count is 0