简体   繁体   English

从存储过程插入返回记录-SQL

[英]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.

相关问题 SQL Server-来自存储过程的模拟记录 - SQL Server - Mock Records from Stored Procedure 插入对象类型并从存储过程返回 - Insert into Object Type and return from Stored procedure SQL Server存储过程从sql批量插入返回失败的记录 - SQL Server stored procedure to return failed records from sql bulk insertion 使用存储过程将记录从用户定义的表类型插入SQL Server数据库 - Insert records into SQL Server database from user defined table type using stored procedure 如何使用存储过程 SQL Server 从表中复制记录并插入到同一个表中 - How to copy records from table and insert into same table using stored procedure SQL Server 如果插入失败,SQL Server存储过程将还原我的记录 - SQL Server stored procedure restore my records if Insert failed 执行存储过程以将记录插入表中-SQL Server 2000 - Executing a stored procedure to insert records into a table - SQL Server 2000 插入新记录并更新SQL Server存储过程中的现有记录 - Insert new records and update existing recordes in SQL Server Stored procedure SQL Server存储过程 - 检查是否存在任何记录,如果不存在则插入 - SQL Server stored procedure - check if ANY records exist, and insert if not 随机记录和SQL2005存储过程插入 - Random Records & SQL2005 Stored Procedure Insert
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM