SSIS OLE DB命令错误:无法推断位置'1'的参数的类型,以远程调用模块'sp_executesql'

如何解决SSIS OLE DB命令错误:无法推断位置'1'的参数的类型,以远程调用模块'sp_executesql'

我在SSIS包中有一个OLE DB Command任务,该任务接收参数,将其插入到链接服务器的表中,并返回在链接服务器上创建的ID。

当我在SSMS中运行查询时,它可以工作,但是在SSIS中,我在主题行中收到错误消息。

OLE DB命令中的sqlCommand是:

DECLARE
    @UserId int = ?,@ContactUsId int = ?,@CreateDate datetime = ?,@Subject nvarchar(500) = ?,@InteractionClusterId int = null  -- We will be testing for this being null

-- removed some irrelevant code here

-- if all else Failed,insert a new record to MngInteractionCluster
if @InteractionClusterId is null
begin
    declare @RemoteQuery nvarchar(max) = N'
    insert into BI_Mng.dbo.MngInteractionCluster
    (
        UserId,ContactUsId,CreateDateTime,[Subject] 
    )
    values
    (
        @UserId,@ContactUsId,@CreateDate,@Subject
    )
  SELECT @InteractionClusterId_OUT = ScopE_IDENTITY()'

    declare @Params nvarchar(1000)  = N'
        @UserId int,@ContactUsId int,@CreateDate datetime,@Subject nvarchar(500),@InteractionClusterId_OUT int OUTPUT'

    EXEC [BI_WAREHOUSE\BI_GLOBAL].master.dbo.sp_executesql
        @RemoteQuery,@Params,@UserId = @UserId,@ContactUsId = @ContactUsId,@CreateDate = @CreateDate,@Subject = @Subject,@InteractionClusterId_OUT = @InteractionClusterId OUTPUT;

end

select
    ? = @InteractionClusterId

在此将其解析为SSIS的任何帮助将不胜感激!

解决方法

我最终将繁重的工作转移到本地服务器上的存储过程中。 现在,OLE DB命令组件中的代码很简洁

DECLARE
    @OriginalMailId int = ?,@UserId int = ?,@ContactUsId int = ?,@CreateDate datetime = ?,@Subject nvarchar(500) = ?,@isAutoReply bit = ?,@BIEnvironmentId int = ?,@InteractionClusterId int

exec BI_Mng.dbo.GetInteractionClusterId
    @OriginalMailId,@UserId,@ContactUsId,@CreateDate,@Subject,@isAutoReply,@BIEnvironmentId,@InteractionClusterId OUTPUT

select ? = @InteractionClusterId

在存储过程中,有一个对链接服务器上sp_ExecuteSQL的远程执行的调用。为了让SSIS解析它,至关重要的是,它必须包含WITH RESULT SETS子句,如下所示:

declare @RemoteQuery nvarchar(max) = N'
insert into BI_Mng.dbo.MngInteractionCluster
(
UserId,ContactUsId,CreateDateTime,[Subject] 
)
values
(
@UserId,@Subject
)
SELECT @InteractionClusterId_OUT = SCOPE_IDENTITY()'

declare @Params nvarchar(1000)  = N'
@UserId int,@ContactUsId int,@CreateDate datetime,@Subject nvarchar(500),@InteractionClusterId_OUT int OUTPUT'

EXEC [BI_WAREHOUSE\BI_GLOBAL].master.dbo.sp_executesql
@RemoteQuery,@Params,@UserId = @UserId,@ContactUsId = @ContactUsId,@CreateDate = @CreateDate,@Subject = @Subject,@InteractionClusterId_OUT = @InteractionClusterId OUTPUT
WITH RESULT SETS NONE;

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

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?