Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Script task using batch file parameters


Script task using batch file parameters

Author
Message
10e5x
10e5x
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 Visits: 180
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.
10e5x
10e5x
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 Visits: 180
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
Tim Mitchell
Tim Mitchell
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1122 Visits: 2913
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


10e5x
10e5x
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 Visits: 180
Hi,
heed your advice i did exactly, and it solved my problem, thanksSmile
Tim Mitchell
Tim Mitchell
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1122 Visits: 2913
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search