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
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