You must Sign In to post a response.
- Category: SQL Server
A transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order, whether in a manual fashion by a user or automatically by some sort of a database program.
Transaction are very important in real time world.
There are following commands used to control transactions:
COMMIT: to save the changes.
ROLLBACK: to rollback the changes.
SAVEPOINT: creates points within groups of transactions in which to ROLLBACK
SET TRANSACTION: Places a name on a transaction.
Lets come to your question.
Commit command is used to permanently save any transaction into database.
Following is Commit command's syntax,
Example like when you are buying some online shopping and you have order an item and payment done through your Online Banking Account. So once the money got transferred. like, Update or Insert statement it should be committed to make the transaction done. Once the Commit is done it is like Over.
- #768024Hi Prasanta Kumar
Transaction is nothing but making use of commit and roll back. If we execute both the statements/conditions successfully it commits. Like any one condition out of two condition is failed then transaction is roll backed(it keeps the records like how it was previously).
If it executes both the conditions the transaction is committed(it updates the records with new values).
Editor: DNS Forum.
Refer the below..
We can write more than one sql statement in transaction with Begin, Commit, rollback transactions. When we put sql statements inside begin transaction, then it means that will be locked, until commit or rollback transaction executed. We can use these because if some issue with some sql statements we can rollback whole transaction instead of commit.
For example if some insertions happen in some set of table then we need to update some other tables. this scenario if any of insertion is failing we will rollback all transactions instead of inserting and updating.
SQL statements uses the BEGIN TRANSACTION, COMMIT TRANSACTION, COMMIT WORK, ROLLBACK TRANSACTION, ROLLBACK WORK, and SET IMPLICIT_TRANSACTIONS statements.
BEGIN TRANSACTION [T1]
INSERT INTO Table1...
COMMIT TRANSACTION [T1]
ROLLBACK TRANSACTION [T1]
Hope this will help you
Never lose hope..You never know what tomorrow will bring