--begin distributed TRANSACTION [Transactionname]
--Flags a TSQL distributed transaction starting with the Distributed Transaction Coordinator MSDTC Management
--server a server as the primary control server. When the connection issues a subsequent commit transaction or
--rollback TRANSACTION statement, the master server requests MSDTC to manage between the servers involved
--Completion of distributed transactions
--sqlserver uses a linked server or remote server as a platform for distributed transaction processing, providing
--Remote stored procedure calls and distributed queries
-When using a distributed transaction for a remote stored procedure call and a distributed query, in server A
--A BEGIN distributed TRANSACTION is issued that invokes the stored procedure on server B
--and another stored procedure on Server C, and the stored procedure on server C executes a
--distributed queries, four SQL Server servers into a distributed transaction, Server A is the creator of the transaction
--and control server
--Create a distributed transaction and delete a record at the local and remote databases, where remote SQL Server
-the instance name is RemoteServer. Both local and remote databases commit or roll back the transaction at the same time.
--note that when executing a distributed query or invoking a stored procedure, a 4-part name is used to qualify the rule
--Prerequisite: The MSDTC of this machine and the MSDTC service of the remote machine to open
--This machine and the remote machine can ping each other
--Database ports can telnet to each other
--Create a linked server to a remote machine win7u-20130414z
Use [Gposdb]
Go
SELECT * FROM [Systempara] WHERE [name]= ' Hdtport '
SELECT * FROM [win7u-20130414z]. [Gposdb].dbo. [Systempara] WHERE [name]= ' Hdtport '
Use [Gposdb]
Go
BEGIN Distributed TRANSACTION
--Delete a record from the local database
DELETE from [JOE]. [Gposdb]. [DBO]. [Systempara]
WHERE [name]= ' Hdtport '
--Deletes a record from the remote database
DELETE from [Gposdb]. [dbo]. [Systempara]
WHERE [name]= ' Hdtport '
COMMIT TRAN
Go
--a personal attempt was made because of the chained access (linkedserver) in bidirectional SQL Server access,
--When you encounter this situation, you only need to use the statement that originally accessed the other database:
--select * from LinkedServerA.dbo.table1
--Modified to:
--select * from Dbo.table1.
--marked down for later resolution.