MSDN上看了一下说是sql server 2005不支持在分布式事务处理中存在指向本地的链接服务器(环回链接服务器)@H_403_1@个人尝试了下是由于在双向的sql server访问中采用了链式方式访问(LinkedServer方式),遇到这种情况只需要将原来访问对方数据库的语句:
代码如下:
403_1@select * from linkedServerA.dbo.table1@H_403_1@
代码如下:
403_1@select * from dbo.table1@H_403_1@
@H_403_1@即可。
触发器代码如下:
代码如下:
403_1@create trigger tgr_dressNotice_insert@H_403_1@on dress_notice_config@H_403_1@ ---with encrypion –--加密触发器@H_403_1@ after insert ----update级别trigger@H_403_1@as@H_403_1@begin@H_403_1@ --as raisError('tgr_dressNotice_insert触发器被触发',16,10);@H_403_1@ /* 定义变量 */@H_403_1@ declare @sDBServer char(20) /*用于存放目的数据库*/@H_403_1@ declare @ssql varchar(600) @H_403_1@ declare @server varchar(100)@H_403_1@ declare @oadb varchar(100) select @oadb=db_server from dic_organ where valid='1' and rank in('A','B') and organ_id='000000'@H_403_1@ set @server=rtrim(@oadb) + '.dbo.spoa_exec_string' /*define cursor*/@H_403_1@ declare db_cursor cursor for @H_403_1@ select db_server from dic_organ where valid='1' and rank in('A','B') and organ_id<>'000000' /*open cursor*/@H_403_1@ OPEN db_cursor@H_403_1@ FETCH NEXT FROM db_cursor @H_403_1@ INTO @sDBServer while(@@Fetch_status = 0)@H_403_1@ begin@H_403_1@ /*将数据同步更新到各个分局的数据库中*/@H_403_1@ set @ssql='delete from ' + RTRIM(@sDBServer) + '.dbo.dress_notice_config' @H_403_1@ print @ssql @H_403_1@ exec @server @ssql@H_403_1@ set @ssql='insert into ' + RTRIM(@sDBServer) + '.dbo.dress_notice_config select * from dress_notice_config' @H_403_1@ print @ssql@H_403_1@ exec @server @ssql FETCH NEXT from db_cursor@H_403_1@ into @sDBServer@H_403_1@ end --最后关闭游标@H_403_1@ close db_cursor@H_403_1@ deallocate db_cursor@H_403_1@end@H_403_1@go@H_403_1@