Today I got an interesting question from Preethy kammath my colleague.
The question is what is the difference between BEGIN….END VS BEGIN TRAN/COMMIT/ROLLBACK?
The answer is
Begin……End delimits a block of code. IF there is no BEGIN TRAN inside the BEGIN…END then each statement will execute in an autonomous transaction.
- BEGIN TRAN…COMMIT TRAN … Rollback
In this each statement inside this block is executed in the same transaction and cannot be committed or rolled back individually.
Hope every one understood the concept. More discussions are welcome.