COMMIT in SQL Server 2008

In this article I describe COMMIT Transactional Command in SQL Server
  • 3533

Introduction

Today we are playing around rollback and commit data control commands. Rollback command is the transactional command. These commands are used to ensure integrity within the database. First of all we create a table on which we enforce commit and rollback commands:

Commit:

When we use commit in our commands than change made by command will be permanent. We can't rollback while using commit command. After commit transaction then transaction can not be rolled back.

Syntax:

begin tran transaction_name
Queries to execute
commit tran transaction_name

where,

transaction_name: is name assigned to the transaction, in place of transaction_name we could specify transaction variable, savepoint name, or savepoint variable.

Queries to execute: defines the list of queries whose result is to be permanent.

Example:

CommitCommand-in-sql.jpg

Output:

CommitCommandOutput-in-sql.jpg


Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.