同步处理的存储过程问题(为什么老是没人回答?高手在哪里?请出手!)

cattydid 2005-02-26 12:11:43
沿用前人的帖子,想实现两台服务器的某两个表的简单同步问题,存储过程的代码如下:
=================================================================================
create proc p_synchro
as
--set XACT_ABORT on
--启动远程服务器的MSDTC服务
--exec master..xp_cmdshell 'isql /S"xz" /U"sa" /P"" /q"exec master..xp_cmdshell ''net start msdtc'',no_output"',no_output

--启动本机的MSDTC服务
--exec master..xp_cmdshell 'net start msdtc',no_output

--进行分布事务处理,如果表用标识列做主键,用下面的方法
--BEGIN DISTRIBUTED TRANSACTION
--同步删除的数据
delete from srv_lnk.test.dbo.[user]
where id not in(select id from [user])

--同步新增的数据
insert into srv_lnk.test.dbo.[user]
select id,number,name from [user] where state is null

--同步修改的数据
update srv_lnk.test.dbo.[user] set
number=b.number,name=b.name
from srv_lnk.test.dbo.[user] a
join [user] b on a.id=b.id
where b.state=1

--同步后更新本机的标志
update [user] set state=0 where isnull(state,1)=1
--COMMIT TRAN
go

================================================================
问题:可不知为什么语法检查没错,就是按ok键是老是弹出错误信息框
Error 7405: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set after the connection. This ensures consistent query semantic, enable these options and then reissue your query.

我在一开始加上:
set ANSI_NULLS on
set ANSI_WARNINGS on
或者
exec sp_dboption 'srv_lnk','ANSI_NULLS ','on'
exec sp_dboption 'srv_lnk',ANSI_WARNINGS ','on'

还是不行,不知问题出在哪?
...全文
77 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧