SQL Server 2005 Run a stored procedure via SSIS using GETDATE() as a Parameter

£可爱£侵袭症+ 提交于 2020-01-15 11:37:20

问题


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?


回答1:


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()

Now wire that variable up to the Execute SQL Task.

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.




回答2:


One possible workaround to consider. You could make GETDATE() the default value for the parameter in the stored procedure and then call it without that parameter.

CREATE PROCEDURE YourProc 
    @InputDate DATETIME = GETDATE()
AS
...


来源:https://stackoverflow.com/questions/9334950/sql-server-2005-run-a-stored-procedure-via-ssis-using-getdate-as-a-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!