Link to home
Start Free TrialLog in
Avatar of justin_smith
justin_smithFlag for Australia

asked on

Passing data variable to SSIS though command line

Hi,

I am trying pass the date of the day of execution to a SSIS variable when executing the package through a bat file

This is what i am doing

dtexec /FILE "C:\Package.dtsx" /set "\package.variables[ExecutionDate].Value";%date%

And i am getting an error as follows

Option "20-04-2009" is not valid.

This tells me that it is understand this date as an option in the command line execution...

Any ideas what this is happening...

Thanks



Avatar of justin_smith
justin_smith
Flag of Australia image

ASKER

by the way, it works when i do the follwoing

dtexec /FILE "C:\Package.dtsx" /set "\package.variables[ExecutionDate].Value";"20-04-2009"
Avatar of Steve Hogg
What type of variable. I started to assume a Date variable, but is it a string?
Its not string.. it is a datetime type
whats interesting is that the above with %date% worked on my development machine..--XP 64 bit

But when i moved it to XP 32 it didnt...

I am a little confused
Avatar of nmcdermaid
nmcdermaid

Are you intending to use the %DATE% reserved dos variable? Is there any reason you don't want to use a function internal to SSIS to work otu the date? is it because you want to be able to run the package for any date?
When I type
ECHO %DATE%
into a DOS prompt I get
Tue 21/04/2009
How about you?
I guess the real test is to go to a DOS prompt and type
ECHO dtexec /FILE "C:\Package.dtsx" /set "\package.variables[ExecutionDate].Value";%date%
and see how it expands. You might find it looks like this:
dtexec /FILE "C:\Package.dtsx" /set "\package.variables[ExecutionDate].Value";Tue 21/04/2009
which would explain why it thinks that  the date is a seperate parameter (formatting aside)
 
nmcdermaid:
excellent

the reason i am passing date is to run SSIS on any date...

any workaround to pass date in the expected format...
How did the echo comde out (as per comment 24191446) ?
How do you intend to run it for a different date? will you build a manual command line and run it manually?
If so, then I suggest you alter your package so that if nothing is passed in for this variable, it automatically assigns it with todays date.
That way, using a command line without setting the parameter performs default behaviour (run for todays date), and a command line with an explicit parameter value will perform it for a given date.
That way you can avoid all that DOS command line hassle - its really not worth the hassle!! Someone in the DOS zone could cook you up an enormous unintelligible inline string to do it, but it really doesn't do much for 'self documentation'
 
However if you want to be able to run this for other dates in other ways, can you let me know how you want to do that.
 
///How do you intend to run it for a different date? will you build a manual command line and run it manually?
yes..

Do you want want me to evaluate the variable as expression to GETDATE()?
ASKER CERTIFIED SOLUTION
Avatar of nmcdermaid
nmcdermaid

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For anyone who is interested, the echo command indeed comes out as
dtexec /FILE "C:\Package.dtsx" /set "\package.variables[ExecutionDate].Value";Thu 23/04/2009