On MSDN, it says SQL Server 2005 does not support the presence of a local linked server (loopback linked server) in distributed transactions
A personal attempt was made by using a chained-mode access (LinkedServer) in bidirectional SQL Server access, which requires only the statements that originally visited the other database:
Copy Code code as follows:
SELECT * FROM LinkedServerA.dbo.table1
Modified to:
Copy Code code as follows:
Can.
The trigger code is as follows:
Copy Code code as follows:
Create Trigger Tgr_dressnotice_insert
On Dress_notice_config
---with encrypion–--encryption triggers
After insert----UPDATE level Trigger
As
Begin
--as raisError (' Tgr_dressnotice_insert triggers are triggered ', 16, 10);
/* Define Variable * *
Declare @sDBServer char (20)/* For storing the destination database * *
DECLARE @sSql varchar (600)
DECLARE @server varchar (100)
DECLARE @oadb varchar (100)
Select @oadb =db_server from Dic_organ where valid= ' 1 ' and rank in (' A ', ' B ') and organ_id= ' 000000 '
Set @server =rtrim (@oadb) + '. Dbo.spoa_exec_string '
/*define cursor*/
DECLARE db_cursor cursor FOR
Select Db_server from Dic_organ where valid= ' 1 ' and rank in (' A ', ' B ') and organ_id<> ' 000000 '
/*open cursor*/
OPEN Db_cursor
FETCH NEXT from Db_cursor
Into @sDBServer
while (@ @Fetch_status = 0)
Begin
/* Synchronize the data to the database in each branch
Set @sSql = ' Delete from ' + RTRIM (@sDBServer) + '. Dbo.dress_notice_config '
Print @sSql
EXEC @server @sSql
Set @sSql = ' INSERT INTO ' + RTRIM (@sDBServer) + '. Dbo.dress_notice_config select * from Dress_notice_config '
Print @sSql
EXEC @server @sSql
FETCH NEXT from Db_cursor
Into @sDBServer
End
--Finally close the cursor
Close Db_cursor
Deallocate db_cursor
End
Go