MSDN上看了一下說是sql server 2005不支持在分布式事務處理中存在指向本地的鏈接服務器(環回鏈接服務器)
個人嘗試了下是由於在雙向的sql server訪問中采用了鏈式方式訪問(LinkedServer方式),遇到這種情況只需要將原來訪問對方數據庫的語句:
復制代碼 代碼如下:
select * from linkedServerA.dbo.table1
修改為:
復制代碼 代碼如下:
select * from dbo.table1
即可。
觸發器代碼如下:
復制代碼 代碼如下:
create trigger tgr_dressNotice_insert
on dress_notice_config
---with encrypion –--加密觸發器
after insert ----update級別trigger
as
begin
--as raisError('tgr_dressNotice_insert觸發器被觸發', 16, 10);
/* 定義變量 */
declare @sDBServer char(20) /*用於存放目的數據庫*/
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
/*將數據同步更新到各個分局的數據庫中*/
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
--最後關閉游標
close db_cursor
deallocate db_cursor
end
go