微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

sql-server – SQL Server链接服务器:“无法在此会话上启动更多事务.”

我正在尝试对链接服务器执行INSERT操作:
DBCC TRACEON (3604,7300)

BEGIN TRANSACTION

INSERT INTO LIVE.Contoso.dbo.Events (EventGUID,EventDate,LoginGUID,UserGUID,EventType,Notes,TargetGUID) 
VALUES ('{494D023F-CD5A-11E2-9F18-C86000D0B92A}',getdate(),'{3B4F90C0-CD5A-11E2-9F18-C86000D0B92A}','{494D023D-CD5A-11E2-9F18-C86000D0B92A}',1,N'Test notes','{494D023E-CD5A-11E2-9F18-C86000D0B92A}')

ROLLBACK TRANSACTION

并返回错误

OLE DB provider “sqlNCLI” for Linked Server “LIVE” returned message “Cannot start more transactions on this session.”.
Msg 7395,Level 16,State 2,Line 3
Unable to start a nested transaction for OLE DB provider “sqlNCLI” for Linked Server “LIVE”. A nested transaction was required because the XACT_ABORT option was set to OFF.

这个本地数据库从2000(查询工作)移到2005(查询无效).远程服务器是2008 R2.

你尝试过什么?

详尽的事情清单from this question that i asked two years ago.

你是如何创建链接服务器的?

--EXEC master.dbo.sp_dropserver @server = N'LIVE'
EXEC master.dbo.sp_addlinkedserver @server = N'LIVE',@srvproduct=N'',@provider=N'sqlOLEDB',@datasrc=N'vader'
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'LIVE',@locallogin = NULL,@useself = N'False',@rmtuser = N'Contoso',@rmtpassword = N'Battery Horse Staple Correct'

但你有什么尝试?

>我禁用了两台服务器上的所有MSDTC安全选项

>检查时钟是否同步(由于某些未知原因会破坏各种身份验证方案,如果它们不同步)

>我在两台服务器上都禁用了防火墙(没有屏幕截图;你只需要相信我)
>离开重新加入域名

服务器的版本是什么?

>本地:Microsoft sql Server 2005 – 9.00.1399.06(Intel X86)2005年10月14日00:33:37版权所有(c)1988-2005 Microsoft Corporation企业版在Windows NT 5.2(Build 3790:Service Pack 2)上
>链接的远程:Microsoft sql Server 2008 R2(SP2) – 10.50.4000.0(X64)2012年6月28日08:36:30版权所有(c)Windows NT 6.1上的Microsoft Corporation Enterprise Edition(64位)< X64> (Build 7601:Service Pack 1)(管理程序)

解决方法

the documentation of SET XACT_ABORT开始:

XACT_ABORT must be set ON for data modification statements in an implicit or explicit transaction against most OLE DB providers,including sql Server. The only case where this option is not required is if the provider supports nested transactions.”

也许您使用的是在2000上支持嵌套事务的提供程序.似乎您需要设置XACT_ABORT.不确定这是否符合您的生产代码所做的事情.

这个答案可能会有所帮助:What is the benefit of using “SET XACT_ABORT ON” in a stored procedure?

原文地址:https://www.jb51.cc/mssql/79568.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐