![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
We are restucturing our databases and I need to change a bunch of DTS Packages' connection info. Is there a way to programatically loop through all packages on the SQL 2000 Server and check for a particular connection, if found then change it and then save the change? Either with ActiveX scripting or VB6? Thanks, Jim james_peppercorn (AT) storagetek (DOT) com |
#3
| |||
| |||
|
|
Thanks. I ended up modifying the "Transfer Packages Sample Application" from SQLDTS.com in VB. I needed to change more than just the connection in the DTS packages, here's what I did: ============ Do While Not oPkgInfos.EOF Set oPkg = New DTS.Package2 ' Load the Pkg oPkg.LoadFromSQLServer "SQLServerName", "", "", DTSSQLStgFlag_UseTrustedConnection, "", "", "", oPkgInfo.Name ' Change SQL Connections For Each oConn In oPkg.Connections If oConn.Catalog = "OldDatabaseName" Then oConn.Catalog = "NewDatabaseName" End If Next 'Change Tasks If oPkg.Tasks.Count > 1 Then For Each oTask In oPkg.Tasks If oTask.CustomTaskID = "DTSDataPumpTask" Then oTask.Properties("DestinationObjectName") = Replace(oTask.Properties ("DestinationObjectName"), "[OldDatabaseName]", "[NewDataba seName]") End If Next End If ' Save the Pkg oPkg.SaveToSQLServer "SQLServerName", "", "", DTSSQLStgFlag_UseTrustedConnection oPkg.UnInitialize Set oPkgInfo = oPkgInfos.Next Loop ============ Jim james_peppercorn (AT) storagetek (DOT) com |
#4
| |||
| |||
|
|
Jim, just a pointless piece of info but the "If oPkg.Tasks.Count > 1 Then" clause is redundant. The For Each will not enter the contained code unless there is at least one instance of a task. -- Darren Green (SQL Server MVP) DTS - http://www.sqldts.com |
![]() |
| Thread Tools | |
| Display Modes | |
| |