Q: setting a variable in DTS

  • hello,

    I was wondering if someone can help me out with the following request:

    I have created a DTS package that will transfer data from one server to another, however, inside the existing data source, I have to manually specify a date.

    How would I go about getting the current data (yyyy/mm/dd) using a variable?

    Thanks.

    -----------------------------
    www.cbtr.net
    .: SQL Backup Admin Tool[/url] :.

  • Since I'm not sure exactly how you are pulling your data I can't get too specific with you, but have you tried using Global Variables?  You can read more about them here.  Also you might want to try a parameterized query which you can read about here.

    To help us help you read this[/url]For better help with performance problems please read this[/url]

  • hey Luke, thanks for responding.

    I have created a global variable with

    Name: CurrentDate

    Type: String

    Value: ??????? STUMPED ???????

    I am not sure what valid I should be using to get the current system date in the format of yyyy/mm/dd

    -----------------------------
    www.cbtr.net
    .: SQL Backup Admin Tool[/url] :.

  • If you're just looking for the current system date you can use this wherever you wanted to use your variable...

    convert(char, DATEADD(dd, DATEDIFF(dd,0,getdate()), 0), 111)

    To help us help you read this[/url]For better help with performance problems please read this[/url]

  • Within an ActiveX Script, you can use the following to set a global variable with the current date...

    DTSGlobalVariables("myDate").Value = Date

  • Bellis, will that give me the yyyy/mm/dd format?

    -----------------------------
    www.cbtr.net
    .: SQL Backup Admin Tool[/url] :.

  • Whenever I run it I get...  11/30/2005

    but this may be due to system settings.  I'm sure you can format it however you want it. 

    You can force the YYYY/MM/DD format with...

    DTSGlobalVariables("myStartDate").Value =

    Year(Date) & "/" & Month(Date) & "/" & Day(Date)

  • thanks, I will give it a shot later this afternoon.

    -----------------------------
    www.cbtr.net
    .: SQL Backup Admin Tool[/url] :.

Viewing 8 posts - 1 through 7 (of 7 total)

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