SQL Server 2005 使用 GETDATE() 作为参数通过 SSIS 运行存储过程 [英] SQL Server 2005 Run a stored procedure via SSIS using GETDATE() as a Parameter
问题描述
我一直在寻找这个问题的答案,但找不到.我想使用 Visual Studio 2005 和 SQL Server 2005 设置一个 SSIS 包,它将今天的日期 (GETDATE()) 作为参数发送到存储过程.我可以找到如何发送参数,但不能找到如何将该参数声明为 GETDATE().这甚至可能吗?
I've been searching for an answer to this and I can't find it. I want to set up an SSIS package using Visual Studio 2005 and SQL Server 2005 that will send today's date (GETDATE())as the parameter to a stored procedure. I can find how to send a parameter, but not how to declare that parameter to be GETDATE(). Is this even possible?
推荐答案
如果你需要一个持续评估时间,比如 GETDATE() 那么,在 SSIS 中创建一个名为 GetDate
的变量,其数据类型为约会时间.右键单击并在属性窗口上,检查 EvaluateAsExpression = True,对于表达式,使用 GETDATE()
If you need a constantly evaluating time, like GETDATE() then, create a Variable in SSIS called GetDate
with a Data Type of DateTime. Right click and on the properties window, check the EvaluateAsExpression = True and for the Expression, use GETDATE()
现在将该变量连接到执行 SQL 任务.
Now wire that variable up to the Execute SQL Task.
如果您暂时不需要,请考虑使用系统范围变量之一.执行 SQL 任务的 ContainerStartTime
可能就足够了.我的首选值是 StartTime
,因为那是包开始执行的时间,但您最清楚哪一个最适合您.
If you don't need this very moment, look at using one of the system scoped variables. The ContainerStartTime
of the Execute SQL Task would probably suffice. My go to value is the StartTime
as that's when the package started execution but you'll know best which one is right for you.
这篇关于SQL Server 2005 使用 GETDATE() 作为参数通过 SSIS 运行存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!