【发布时间】:2019-08-20 15:03:24
【问题描述】:
在 SSIS 的 OLE DB 源中执行存储过程时遇到问题,
我已将 OLE DB 源设置为 SQL 命令并输入以下内容:
这是 SQL 命令文本的代码:
exec timesheet_r12..TIME_lynx_extract ?,?,?,?,?,?,?,?,?,?,?,?,?
WITH RESULT SETS (
(
worker_reference NVarchar(50),
placement_reference NVarchar(10),
worker_name NVarchar(50),
job_title NVarchar(100),
authorising_line_manager NVarchar(100),
timesheet_date datetime,
company_agent_name NVarchar(100),
type_of_worker NVarchar(100),
week_number NVarchar(100),
hours_worked NVarchar(100),
rate_description NVarchar(100),
rate_per_hour NVarchar(10),
job NVarchar(100),
work_stage NVarchar(100),
project_name NVarchar(100),
location NVarchar(100)
)
)
我需要发送的前 2 个参数是 @startweek 和 @endweek 对于这些,我需要了解如何将最后一个星期五发送为“@endweek”,将 4 周前的星期五发送为“@startweek”(前 4 个星期五)。
如果我想使用硬编码的@startweek 和@endweek 执行数据库中的存储过程,我可以使用以下命令:
exec timesheet_r12..TIME_lynx_extract
'19 Jul 2018',
'16 Aug 2019',
null,null,null,null,null,null,null,null,null,null,null
这是我在 SSIS 中执行包时遇到的错误:
SSIS package "C:\Users\AGUIRRG2\source\repos\Integration Services Project3\Integration Services Project3\Package.dtsx" starting.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at Data Flow Task, SSIS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at Data Flow Task, SSIS.Pipeline: Pre-Execute phase is beginning.
Error: 0xC0207014 at Data Flow Task, OLE DB Source [49]: The SQL command requires a parameter named "@startweek", which is not found in the parameter mapping.
Error: 0xC004701A at Data Flow Task, SSIS.Pipeline: OLE DB Source failed the pre-execute phase and returned error code 0xC0207014.
Information: 0x40043008 at Data Flow Task, SSIS.Pipeline: Post Execute phase is beginning.
Information: 0x4004300B at Data Flow Task, SSIS.Pipeline: "Excel Destination" wrote 0 rows.
Information: 0x40043009 at Data Flow Task, SSIS.Pipeline: Cleanup phase is beginning.
Task failed: Data Flow Task
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (2) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "C:\Users\AGUIRRG2\source\repos\Integration Services Project3\Integration Services Project3\Package.dtsx" finished: Failure.
The program '[24756] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).
所以现在我需要知道如何将参数传递给 SSIS,以及如何使它们动态化,@startweek 和 @endweek 可以计算出来。
谢谢。
【问题讨论】:
-
创建 2 个日期数据类型的 SSIS 变量并使用表达式设置它们,然后将它们提供给 EXEC 脚本。由于 SSIS 表达式不是最好的,我建议在您的 SQL Server 上创建一个日历表和一个标量函数,并使用它来查找最后一个星期五(4 周前的最后一个星期五只是减去 4 周)。
-
此外,如果您必须以 varchar 形式提供日期,请确保使用 YYYY-MM-DD 格式并不惜一切代价避免使用特定于语言的名称。
-
我刚刚尝试过这样做:i.imgur.com/uJX7ovB.png 我得到了同样的错误
-
它不能通过传递参数来工作,因为我的存储过程会在 sql server 中使用它?另外,我没有看到 varchar 作为 SSIS 中的数据类型
标签: sql-server stored-procedures ssis