[英]Insert return records from stored procedure - SQL
The script below return a select records: 下面的脚本返回一个选择记录:
EXEC [LINK_SERV].[DB_SAMPLE].[dbo].[SP_SAMPLE] '1235123'
The I want to insert the return records to a temp table so I wrote the script below (assumed temp table is already created): 我想将返回记录插入到临时表中,所以我在下面编写了脚本(假设已经创建了临时表):
INSERT INTO #TempTable
EXEC [LINK_SERV].[DB_SAMPLE].[dbo].[SP_SAMPLE] '1235123'
But I get this error: 但是我得到这个错误:
OLE DB provider "SQLNCLI11" for linked server "LINK_SERV" returned message "The partner transaction manager has disabled its support for remote/network transactions.
链接服务器“ LINK_SERV”的OLE DB提供程序“ SQLNCLI11”返回消息“合作伙伴事务管理器已禁用其对远程/网络事务的支持。
Msg 7391, Level 16, State 2, Line 25
消息7391,第16级,州2,第25行
The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "LINK_SERV" was unable to begin a distributed transaction.由于链接服务器“ LINK_SERV”的OLE DB提供程序“ SQLNCLI11”无法开始分布式事务,因此无法执行该操作。
Please advise the specific config to enable this. 请告知具体配置以启用此功能。 I tried the same code in some other server and it work.
我在其他服务器上尝试了相同的代码,并且可以正常工作。 Thank you in advance.
先感谢您。
This is where the beauty of OPENQUERY() comes into great use. 这就是OPENQUERY()之美得到充分利用的地方。
ie something like this... 即像这样的东西...
INSERT INTO dbo.MyTable2
SELECT Col1, Col2, etc
FROM dbo.MyTable1
LEFT JOIN OPENQUERY(<<LINKEDSERVER>>,
'SELECT BLAHBLAH
FROM dbo.BLAHBLAH WHERE <something> = <something>);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.