sql-server-2008 - SSIS 2008 Execute SQL输出参数映射datetime2问题

标签 sql-server-2008 ssis types parameters datetime2

我正在尝试使用 SSIS 2008 中的执行 SQL 任务将存储过程输出参数映射到包变量。

包变量为SSIS类型DateTime,存储过程参数为SQL类型DATETIME。

SQL 语句是 EXEC GetCurrentDate @CurrentDate=? 并且在参数映射屏幕中,参数映射到指定方向输出和数据类型 DBTIMESTAMP 的包变量。

当我运行包时,出现以下错误:

[Execute SQL Task] Error: Executing the query "EXEC GetCurrentDate @CurrentDate=? " failed with the following error: "The type of the value being assigned to variable "User::CurrentDate" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

如果我对正在运行的查询运行跟踪,我会看到类型被假定为 datetime2:

declare @p3 datetime2(7)
set @p3=NULL
exec sp_executesql N'EXEC GetCurrentDate @CurrentDate=@P1 ',N'@P1 datetime2(7) OUTPUT',@p3 output
select @p3

有谁知道为什么假设类型是 datetime2?

谢谢

最佳答案

在 Micorsoft Connect 错误报告中找到答案:

We are closing this case as this is expected behaviour and is a result of the new sql datetime type change. You are using a native oledb connection manager for sql task, in the process of COM interop, we use VARIANT to hold the value and the only way to prevent data loss is to store the value as BSTR variant. If you change User::dateParam to String type it will work, or you can switch to use managed connection manager to bypass the COM interop.

http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=307835

关于sql-server-2008 - SSIS 2008 Execute SQL输出参数映射datetime2问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/876886/

相关文章:

mysql - 计算 SQL 中具有别名的列的出现次数

设计器组件出现 SSIS 2012 SP1 "Value of null is not valid for stream"错误

c++ - c++声明中的::type是什么意思?

types - ocaml 中的类型级别整数

sql-server - 为过程或函数cdc.fn_cdc_get_all_changes_提供的参数数量不足

sql - 使用 WHILE LOOP 在 SQL Server 2008 中迭代 SELECT 语句

asp.net - 数据绑定(bind) : 'System.Data.DataRowView' does not contain a property with the name 'ProductID'

SSIS 派生列 - REPLACENULL 将列宽加倍

ssis - 在 SQL Server 代理作业中运行时,有没有办法找出当前在 SSIS 中运行的任务?

c# - IEnumerable<T>.Intersect<T> 中的 Type 参数有什么作用?