Use transactions where possible to protect me from me.

I did a dumb thing so updated the SQL to protect future brain farts of the same type.