1

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?

DataGirl
  • 429
  • 9
  • 21
  • 1
    If you really need to pass `GETDATE()` as a parameter to your stored procedure, you can just execute the SQL query it with `GETDATE()` instead of assign it to a parameter first – Lamak Feb 17 '12 at 20:37
  • @Lamak, I actually have a couple of different stored procedures that all need today's date and I was hoping to just create one variable in the SSIS and pass it to all of them as they were run. I just couldn't figure out how to do it for one to move on to the others. – DataGirl Feb 17 '12 at 21:15

2 Answers2

3

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.

billinkc
  • 59,250
  • 9
  • 102
  • 159
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
...
Joe Stefanelli
  • 132,803
  • 19
  • 237
  • 235