I'm developing a website, so when a user hits a button the following sample sql code is run. This is for registeration and basically meant to take information entered in a form and save it.
BEGIN TRAN
*sql code*
*sql code*
COMMITT TRAN
BEGIN TRAN
*sql code*
COMMITT TRAN
IF *sql code*
BEGIN
ROLLBACK TRAN
END
in the above code there are several transactions - information being inserted into several tables, if not all goes as planned we rollback the transactions. But if someone presses the button for this script to execute then suddenly hits the 'x' or stop execution button on their browser; leading the execution of the code to stop and never reach the point where the transaction can be rolled back what can we do then?
This will mean the database can often end up with tables that have half filled columns or some linked tables where table X that is linked to table Y doesn't contain any information. Can this kind of thing even happen? Sorry I'm not too well versed in sql 'transactions' at the moment so any help would be nice.