尝试通过 SSIS 中的“执行 SQL 任务”执行存储过程时出错

问题描述

我已经创建了一个存储过程。在尝试通过 SSIS 执行它时,我遇到了问题。

我的存储过程的定义如下所示:

CREATE PROCEDURE dbo.[procedurename] 
    @startDate DATETIME,@endDate DATETIME,@cumulativeAverage DECIMAL(5,2) OUTPUT
AS
    /*stored procedure body that return a table with 3 columns and assigns value to output variable*/
    RETURN 
GO

我能够运行这是 SSMS,它工作正常。但是当我尝试在 SSIS 的 Execute sql 任务中运行它时,它不起作用并且我收到此错误

错误:0xC002F210 在 EXEC 执行 sql 任务名称。执行 sql 任务:执行查询 EXEC DBO.procedurename ?,?,?..." 失败,出现以下错误:多个 OLE DB 操作生成错误。检查每个 OLE数据库状态值...

我的 SSIS 脚本如下。

Result set : Full result set.
sql source type : direct input.
sql statement : EXEC dbo.[procedurename] ?,? OUTPUT

Parameter mappings : variable name- User::startDate,Direction- Input,Data Type- Date,Parameter 
                     Name- 0,Parameter size- -1
                     variable name- User::endDate,Parameter Name- 
                     1,Parameter size- -1
                     variable name- User::cumulativeAverage,Direction- output,Data Type- numeric,Parameter Name- 2,Parameter size- -1
Result set : Result name- 0,Variable name- User::ResultSet
Variables : Variable name- CumulativeAverage,Scope- package,Datatype- Decimal,Value- 0
            Variable name- EndDate,scope- Package,Datetype- DateTime,Value- 5/03/2021
            Variable name- StartDate,Value- 12/28/2020
            Variable name- ResultSet,DateType- Object,Value- System.Object

解决方法

正如@billinkc 所指出的,我能够为我隔离问题。该问题是由 @cumulativeAverage DECIMAL(5,2) OUTPUT 参数引起的。这是因为我无法在 SSIS 中设置变量的精度。虽然,我仍然无法找到设置精度的方法。我更改了 SP 以返回 FLOAT 参数的 OUTPUT 值,将 SSIS 变量配置为除了 FLOAT 数据类型,现在它可以正常工作了。