T-SQL Tutorial

T-SQL Begin Distributed Transaction


A distributed transaction is an operations transaction that can be run on multiple different servers.





Begin distributed transaction syntax:

BEGIN DISTRIBUTED { TRAN | TRANSACTION }
[ transaction_name | @transaction_name_variable ] ;

Begin distributed transaction example:

USE model;
GO
BEGIN DISTRIBUTED TRANSACTION;
--> Delete students from local instance.
DELETE students WHERE id = 7;
--> Delete students from remote instance.
DELETE RemoteServer.students WHERE id = 7;
COMMIT TRANSACTION;
GO