in reply to DBI and transactions

>> Shouldn't table A be rolled back to 0?

no. Since, in your code, you are committing each row, a rollback will only affect the current row being executed. if you want the entire block to rollback, you will have to commit only at the end of the transaction.

so you should use the code you listed in part 2.

eval { #table A foreach line (...) { prepare, execute } #table B prepare, execute } if ( $@ ) { rollback } else { commit; }
Also, while using DBI, make sure you turn off autocommit, i.e.:
my $dbh = DBI->connect('DBI:MSSQL:database', {AutoCommit => 0}, ) or die "Couldn't connect to database: " . DBI->errstr;
otherwise you may be committing each row automatically; it depends on the DBD default setting.

--
.dave.