SSIS 2008执行SQL输出参数映射datetime2问题
我正在尝试使用 SSIS 2008 中的执行 SQL 任务将存储过程输出参数映射到包变量。
包变量是 SSIS 类型 DateTime,存储过程参数是 SQL 类型 DATETIME。
SQL 语句为 EXEC GetCurrentDate @CurrentDate=?,在参数映射屏幕中,参数映射到包变量,并指定方向输出和数据类型 DBTIMESTAMP。
当我运行该包时,出现以下错误:
[执行 SQL 任务] 错误:正在执行 查询“EXEC GetCurrentDate @当前日期=? “ 失败了 以下错误:“的类型 被赋给变量的值 “User::CurrentDate”与 当前变量类型。 变量可能 执行期间不改变类型。 变量类型是严格的,除了 对象类型的变量。 “。 可能的 失败原因: 问题 查询,“ResultSet”属性未设置 正确,参数未设置 正确,或连接不正确 建立正确。
如果我对正在运行的查询进行跟踪,我会看到类型被假定为 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?
谢谢
I'm trying to use an Execute SQL Task in SSIS 2008 to map a store procedure output parameter to a package variable.
The package variable is SSIS type DateTime and the store procedure parameter is SQL type DATETIME.
The SQL Statement is EXEC GetCurrentDate @CurrentDate=?
and in the parameter mapping screen, the parameter is mapped to the package variable with direction Output and Data Type DBTIMESTAMP specified.
When I run the package I get the following error:
[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.
If I run a trace on the query being run I see the type is being assumed as 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
Does anyone know why it is assuming the type is datetime2?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Microsoft Connect 错误报告中找到了答案:
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback。 aspx?FeedbackID=307835
Found the answer on a Micorsoft Connect bug report:
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=307835
尝试在 SSIS 任务中将输入/输出参数指定为
DATE
而不是DBTIMESTAMP
。这在我开发过的 SSIS 2005 包中确实有效。
还值得一看此链接,其中涵盖了此问题以及 SSIS 和日期的其他几个问题。
Try specifying the inout/output parameters as
DATE
rather thanDBTIMESTAMP
in the SSIS task.This certainly works in SSIS 2005 packages I've worked on.
It's also worth taking a look at this link, which covers this as well as a couple of other issues with SSIS and dates.