![]() |
![]() |
![]() |
MSSQL Transaction Question Say I have 200 - 300 update statements that get sent in a batch to SQL Server and all are encompassed in one transaction.
Wayne
To me, the best plan would be to check after each statement, then you won't waste loads of resources creating changes that will ultimately get rolled back.
Steve Jones (UK)
How often do you expect errors?
Rob Walker
I don't expect errors often, because the SQL is generated by my own process. The error handling is there in the off chance that something goes horribly wrong like the disk running out of space or some.
Wayne
Error gets overwritten after each statement. If, for some reason, one update failed, and the next one succeeded, @@ERROR will be set back to 0.
Dennis Forbes
With MS SQL, you *have* to check it after each statement, otherwise you might miss an error. It resets to 0 as each statement is executed. If you wait, and only check it every N statements, you might miss potential errors.
Sgt. Sausage
Whoops, I have some code to go fix. I thought I tested that!
Wayne
This is exactly when an exception-throwing language would come in handy.
Data Miner
T-SQL will (apparently) become an exception-throwing language with the next version.
Steve Jones (UK)
|