I would like to write an SQL script that executes several separate SQL statements; if any of these statements fails, I would like to cancel the entire transaction. So something like:
BEGIN TRANSACTION insert into TestTable values (1) insert into TestTable values (2) insert into TestTabe values (3)
This is for MS SQL 2008. Is there anything I can do for this? Perhaps some kind of exception handling?
I understand that in my example, I could check the TestTable for these values ββand determine if these statements worked in this way. But actually, my SQL will be much more complicated, and I'd rather digress from knowing what SQL does.
source share