[quote]Really? As far as I know the standard behavior is that an exception does not influencde the transaction. You raise an exception, any currently open transaction remains open and the code continues.
I said if
. As you say, there are errors that only terminate the current statement and where execution continues with the next statement, and no transaction is rolled back.
There are some errors that cause a tranaction to be rolled back, e.g. selecting a non existing table
That error aborts the current scope, and does not roll back the transaction (unless XACT_ABORT is ON). That's also bad.
Of course Microsoft tells us to use THROW instead of RAISERROR. They alwalys do when introducing a new command and marking the "old" command as deprecated.
Note that RAISERROR is not deprecated. There are things you can do with RAISERROR that you cannot do with ;THROW. (WITH NOWAIT, WITH NOLOG, set severity level.)
Erland Sommarskog, SQL Server MVP, www.sommarskog.se