What is difference between tran and transaction in SQL Server 2005

q1qsirdb  于 2023-03-17  发布在  SQL Server
关注(0)|答案(3)|浏览(200)

What is difference between tran and transaction in SQL Server 2005 ?

Following are two statements

Begin Tran
Begin
   .........
   .........
End
Rollback

OR

Begin Transaction
Begin 
   ......
   ......
End
Rollback
8e2ybdfx

8e2ybdfx1#

There is a slight difference, the functionality is the same for both begin tran and begin transaction.

If you were to add BEGIN TRANSACTION (or BEGIN TRAN) before the statement it automatically makes the transaction explicit and holds a lock on the table until the transaction is either committed or rolled back.

kknvjkwl

kknvjkwl2#

There is no difference. TRAN is merely an allowed abbreviation, as can be seen from the documentation :
Syntax

BEGIN { TRAN | TRANSACTION } 
    [ { transaction_name | @tran_name_variable }
      [ WITH MARK [ 'description' ] ]
    ]
[ ; ]

The { | } in this syntax description means 'pick one of these two alternatives'

nx7onnlm

nx7onnlm3#

They are synonymous in Transact SQL, it seems that the same logic have been implemented in MDX...

相关问题