Help with DTSRun and multiple Global Variable declaration

  • I have a DTS Package with 4 Global Variables defined.  Each Global Variable's name was created with no spaces (ImportFile, TargetServer, TargetDatabase, TargetTable)

    Each Global Variable is a string (:TypeID=8)

    How do you assign values to each Global Variable via the xp_cmdshell "DTSRun... /A" command.

    Each Global Variable has a default value and it seems that the default is always being used.

    Thanks for the help,

    Scott

  • Example:

    dtsrun /E /S ServerName /N NameOfPackage /A FirstVariable:8=Value /A SecondVariable:8=Value /A ThirdVariable:8=Value

    The /E is for a trusted connection

    And they are case sensitive!

    Hope this helps

    Diane 

  • Diane is correct. Just wanted to add one more thing, that is, make sure to use variable names with exactly same cases in DTSRUN command, as SOMETIME it behaves like variable names are case-sensitive.

  • The simplest way of doing it is to launch a Win32 utility called :

    DTSRUNUI.EXE

    You will find it in Program Files\Microsoft Sql Server\80\Tools\binn

    It has an "Advanced" button that will allow you to enter global variable values. When you are finished use the "Generate" button and copy the generated command line to the clipboard.

    HABIB.

     


    Kindest Regards,

    Habib Zmerli (MVP)

  • It's easier if assign the variables first and use a string to execute the dtsrun line:

     

    declare @var1 as varchar(50)

    declare @var2 as varchar(50)

    declare @var3 as varchar(50)

    declare @var4 as varchar(50)

    --set all you variables here

    declare @STR as varchar(3000)

    set @STR = 'dtsrun /Sservername /Npackagename /E /A "gv1":"8"="' + @var1 + '"' + ' /A "gv2":"8"="' + var2 + '"' + ' /A "gv3":"8"="' + @var3 + '"' + ' /A "gv4":"8"="' + @var4 + '"'

    exec master..xp_cmdshell @STR


    ------------------------------
    The Users are always right - when I'm not wrong!

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

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