In message <457E1827-A22C-41E8-9578-3FB70B4AC976 (AT) microsoft (DOT) com>, SQL
Junior <SQL (AT) Junior (DOT) ?.microsoft.com.invalid> writes
Quote:
for DTS PackageHi
I have created many DTS Packages that use Send Mail Task to send email to
abc (AT) test (DOT) com, how can I change them to abc (AT) test1 (DOT) com without manually
changing it (too tedious). Is there any like replace function or utility for
DTS Package that can replace test.com to test1.com.
Thanks for any advice |
Write some code like this, (not checked).
Enumerate packages, loading each one. Enumerate tasks, looking for send
mail tasks. Grab the custom task object and set the to address.
Dim oDTSApp As DTS.Application
Dim oPkgSQLServer As DTS.PackageSQLServer
Dim oPkgInfos As DTS.PackageInfos
Dim oPkgInfo As DTS.PackageInfo
Dim oPkg As DTS.Package2
Dim oTask As DTS.Task2
Dim oMailTask As SendMailTask
' Enumerate Packages
Set oDTSApp = New DTS.Application
Set oPkgSQLServer = oDTSApp.GetPackageSQLServer("SourceServer", "",
"", DTSSQLStgFlag_UseTrustedConnection)
Set oPkgInfos = oPkgSQLServer.EnumPackageInfos("", True, "")
' Loop through Packages
Set oPkgInfo = oPkgInfos.Next
' "Column does not exist" error on SQL 7.0 because sysdtspackages
lacks packagetype column
Do While Not oPkgInfos.EOF
Set oPkg = New DTS.Package2
' Load the Pkg
oPkg.LoadFromSQLServer "SourceServer", "", "",
DTSSQLStgFlag_UseTrustedConnection, "", "", "", oPkgInfo.Name
' Change SQL Connections
For Each oTask In oPkg.Tasks
If oTask.CustomTaskID = "DTSSendMailTask" Then
Set oMailTask = oTask.CustomTask
oMailTask.ToLine = "spam (AT) sqldts (DOT) com"
End If
Next
' Save the Pkg
oPkg.SaveToSQLServer "DestServer", "", "",
DTSSQLStgFlag_UseTrustedConnection
oPkg.UnInitialize
Set oPkgInfo = oPkgInfos.Next
Loop
' Clean Up
Set oMailTask = Nothing
Set oTask = Nothing
Set oPkg = Nothing
Set oPkgInfo = Nothing
Set oPkgInfos = Nothing
Set oPkgSQLServer = Nothing
Set oDTSApp = Nothing
--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com
PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org