---
title: "how to use commit or rollback statement in the the SQL"  
description: "how to use commit or rollback statement in the the SQL"  
author: "Elena Glibart"  
published: 2016-09-30  
updated: 2016-09-30  
canonical: https://www.mindstick.com/forum/34187/how-to-use-commit-or-rollback-statement-in-the-the-sql  
category: "database"  
tags: ["sql server"]  
reading_time: 1 minute  

---

# how to use commit or rollback statement in the the SQL

Hi Please tell me how to use commit or [rollback](https://www.mindstick.com/forum/157683/explain-commit-rollback-and-savepoint-statements-with-examples-in-pl-sql) statement in the the [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database)\
thanks

## Replies

### Reply by Abhishek Srivasatava

Hi [Elena Glibart](https://www.mindstick.com/Account/1173),

Below is the answer for your question:

**SQL COMMIT Statement:**

It is mainly use while creating transaction for SQL query.

Transaction is the set of statement to perform the task.

COMMIT statement is used to save the changes performed by the transaction statement.

```
BEGIN TRAN  TR1 --(Creating transaction) INSERT INTO EE_EMPL_CAT4 (PRSN_INTN_ID, [EMPL_STAT_CD],[NAME],REFERENCE_ID)    VALUES (565545, 'ACTIVE', 'R Raturi',159978)     COMMIT;  GO
```

**SQL ROLLBACK Statement:**

Rollback is used if there is any sort of error occurs while performing any set of transaction.

For example there are 3 table, data need to update in all three table. If this task need to be done by single transaction then by chance any table is not able to update because of any reason then rollback function undo all the changes.

\

```
BEGIN TRAN  TR1 INSERT INTO EE_EMPL_CAT4 (PRSN_INTN_ID, [EMPL_STAT_CD],[NAME],REFERENCE_ID)    VALUES (56116545, 'ACTIVE', 'DAVID',159978)   ROLLBACK ; GO
```


---

Original Source: https://www.mindstick.com/forum/34187/how-to-use-commit-or-rollback-statement-in-the-the-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
