DTS - can changes to package be scripted?

  • Is it possible to script changes to DTS packages? I would like to script (with whatever tool can do it) changes to connection information (server, userid/pwd)

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • You can use a Dynamic Properties Task, or you can run this script as an Active X script task before you do your other steps (code is directly off of http://www.sqldts.com website).

    Function Main()

    Dim oConn, sFilename

    ' Filename format - exyymmdd.log

    sFilename = "ex" & Right(Year(Now()), 2)

    If Month(Now()) < 10 Then sFilename = sFilename & "0" & _

        Month(Now()) Else sFilename = sFilename & Month(Now())

    If Day(Now()) < 10 Then sFilename = sFilename & _

        "0" & Day(Now()) Else sFilename = sFilename & Day(Now())

    sFilename = DTSGlobalVariables("LogFilePath").Value & _

        sFilename & ".log"

    Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)")

    oConn.DataSource = sFilename

    Set oConn = Nothing

    Main = DTSTaskExecResult_Success

    End Function

  • The packages I need to update with new connection information already exist in an SQL Server. Currently, I  open the package in designer and modify the connections. I would like to script the changes instead of opening each package.

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • If you need only to change the connection parameters (server, database, table name, etc), then I would add a dynamic task, creating a global variable for these. Then you can call it from the DOS command line or via T-SQL using xp_cmdshell...

    dtsrun /S server /U username /P password

    /M packagepassword

    /N packagename

    /A"SQLCatalog:8=northwind"

    /A"SQLTable:8=northwind.dbo.table1" 

    /A"OracleTable:8=SalesDb.table2"

    /A"OracleDb:8=SalesDb" 

    where /A defines the source and destination databases/tables currently defined as connection tasks in the dts package.

     


    smv929

  • Thank you for the input. I just finished reading todays' article on DTS Logging and I think using SQL-DMO would be the way to go. Now I just need to get up to speed on Active X.

    Thanks again

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

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

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