Written By:- Isha Malhotra (Software Developer)
Email:-malhotra.isha3388@gmail.com.
Note: -if you find this article helpful then kindly leave your comment
For Asp.net Training with C# and Sql Server Click Here
Use of Transaction in Sql Server
When we required to run many statements as a single unit
means either all statements run successfully or if single statement failed then
all statement should be discarded in this situation, for this we use
transaction.
Suppose we have two tables, first is personal_info and
second is password_info. When a user insert the record in both tables, in case
record inserted in personal_info and while inserting in second table there is
some error then first table insetion should be cancelled. Becoz record will be
entred in both table otherwise not.
This can be possible by transaction. There commands are used
to manage the transaction and these are following:-