Script task using batch file parameters

  • Hi all,

    I have created a batch file to run my SSIS package. I will be able to pass parameters in my batch file such as 20121228 (YYYYMMDD format) I have created a package variable named ExecDate of string type in SSIS. And inside script task i have a line of code as:

    Dim runDate As DateTime = Now

    now instead of declaring runDate as current datetime, i would like to change it to if ExecDate = "Default", runDate = Now

    else

    runDate = to the parameter i passed in the batch file.

    Note: my ExecDate is of String datatype

    Thanks in advance, pros please help

    update: i think i have solve the above problem by advising user to only pass in parameters of 2012/12/28 format and using a CDATE function to convert it to date.

  • I met with another problem. Lets say using the same package variable ExecDate, data type : String, Default value : "Default"

    So if my batch file pass a date parameters to the variable it will used the date pass, else it shall use today date and not the value "Default". How to do this in a Execute SQL task? I got a statement of

    Delete From T1 Where creationDate = ?

    This wont work as i wont want the value "Default". Any advice? My column creationDate is of datetime type

    thanks

  • When building a package that allows the user the option of specifying a value for a date variable, I'll set the value of that variable to something unusual, such as 01/01/1899. I'll then use a script task to check that variable to see if it is still set to the default, and if it is, I'll use the current date. If the value is not set to the default, I can assume that a date value has been specified, and I'll use that instead.

    hth,

    Tim

    Tim Mitchell, Microsoft Data Platform MVP
    Data Warehouse and ETL Consultant
    TimMitchell.net | @Tim_Mitchell | Tyleris.com
    ETL Best Practices

  • Hi,

    heed your advice i did exactly, and it solved my problem, thanks:)

  • Great! Glad it worked out. Thanks for the follow up.

    Tim Mitchell, Microsoft Data Platform MVP
    Data Warehouse and ETL Consultant
    TimMitchell.net | @Tim_Mitchell | Tyleris.com
    ETL Best Practices

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply