always always always use BEGIN TRANSACTION before updating database with query

so that you can rollback if you don’t get the expected results using rollback transaction

if you don’t use BEGIN TRANSACTION, then you will have to revert the database to a backup to restore the data

if you get the expected results from the transaction, then you must run the commit transaction command

BEGIN TRANSACTION
UPDATE table
SET field = field
FROM
onetable
JOIN
twotable
ON
table1field= table2field
WHERE something= something
and something<> something

–then either issue COMMIT TRANSACTION or ROLLBACK TRANSACTION

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.