devxlogo

SQL commands SET IMPLICIT_TRANSACTIONS vs. BEGIN TRANSACTION

SQL commands SET IMPLICIT_TRANSACTIONS vs. BEGIN TRANSACTION

In ANSI SQL, you are always in a transaction, because there is no BEGIN TRANSACTION statement. The purpose of the SET IMPLICIT_TRANSACTIONS command in SQL 7.0 is to allow T-SQL to be used in a way that is closer to standard SQL transaction semantics. Setting Implicit transactions ON begins a transaction on the server for each statement, and commits do not occur until they are issued manually. The transaction will not be rolled back or committed unless the user issues the commits or rollbacks statement. Thus, without IMPLICIT_TRANSACTIONS, each command is internally converted to:
begin tran
insert
commit tran
begin tran
insert

Compare this to the following if SET IMPLICIT_TRANSACTIONS is ON where the transaction continues till user issues specific commands:
begin tran
insert
insert
commit tran
(user issued command)

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist