user2373198
user2373198

Reputation: 147

What is the difference between Transaction and Try Catch in SQL

What is the difference between using transaction and Try catch in the case of uncommitted return ? in other word in a transaction, if we return in the middle of SP without commit or rollback that table will be locked, I'm now wondering what happens to that table if I use try catch instead of begin transaction and End Transaction ?

Upvotes: 1

Views: 1091

Answers (1)

Sparky
Sparky

Reputation: 15085

A transaction is an instruction to SQL to place a semaphore lock on tables contained with the transaction. You can COMMIT the changes, updating the tables and releasing the lock or ROLLBACK, undoing the changes and releasing the lock.

Try Catch by itself has not impact of table locking... It is strictly error handling within the scope of a procedure. What happens to the transaction is under your control...

Upvotes: 2

Related Questions