January 30, 2007 at 1:27 pm
i'm trying to query the connection objects
in a dts packages, but having trouble getting
to that kind of information.
is this possible?
i've already checked the following tables,
and couldn't find any thing.
sysdtscategories
sysdtspackagelog
sysdtspackages
sysdtssteplog
sysdtstasklog
just wondering if there was another way to do this.
thanks in advance.
_________________________
January 30, 2007 at 6:35 pm
If the dts package stored in MSDB, it will be stored in sysdtspackages table but you can't query the Package configuration...because it is stored in hex format in sysdtspackages.packagedata column.
You may need to write VB code...to do this...OR save the package as VB file and search...
MohammedU
Microsoft SQL Server MVP
January 31, 2007 at 6:59 am
well... instead of reinventing the wheel up front, i'll
think i'll browse the net for some scripts which will do this.
i'll also deconstruct one of the packages via vb, and see what
i can see.
thanks for the reply.
_________________________
January 31, 2007 at 9:28 am
I received help from Nigel Rivett's Activex script which I have modified and is listed below. Remember to include the necessary global variables in your DTS package. Each package is scripted in its own file in the directory specified in one of the global variables.
'**********************************************************************
' Visual Basic ActiveX Script
' Author Nigel Rivett
' http://www.nigelrivett.net/ScriptDTSProperties.html
'************************************************************************
Function Main()
Dim sServerName
Dim sPath
Dim sUserName
Dim sPassword
Dim iTrusted
sServerName = DTSGlobalVariables("ServerName").Value
sPath = DTSGlobalVariables("Path").Value
sUserName = DTSGlobalVariables("UserName").Value
sPassword = DTSGlobalVariables("Password").Value
if len(sUserName) = 0 then
iTrusted = "Y"
else
iTrusted = "N"
end if
iTrusted = "Y"
ScriptDTSPackages sServerName, sPath, iTrusted, sUserName, sPassword
Main = DTSTaskExecResult_Success
End Function
Private Sub ScriptDTSPackages(sServerName, sPath, iTrusted, sUserName, sPassword)
Dim objCon
Dim objCmd
Dim objRsPackageNames
Set objCon = CreateObject("ADODB.Connection")
if iTrusted = "Y" then
objCon.ConnectionString = "Provider=sqloledb;" & _
"Data Source=" & sServerName & ";" & _
"Initial Catalog=" & "msdb" & ";" & _
"Integrated Security=SSPI"
else
objCon.ConnectionString = "Provider=sqloledb;" & _
"Data Source=" & sServerName & ";" & _
"User Id=" & sUserName & ";" & ";" & _
"Password=" & sPassword & ";" & _
"Initial Catalog=" & "msdb"
end if
objCon.CursorLocation = 3 'adUseClient
objCon.Open
Set objCmd = CreateObject("ADODB.Command")
objCmd.ActiveConnection = objCon
objCmd.CommandType = 1 'adCmdText
objCmd.CommandText = "select distinct name from sysdtspackages order by name"
Set objRsPackageNames = CreateObject("ADODB.Recordset")
Set objRsPackageNames = objCmd.Execute
'ScriptDTSPackage "alantest", frmInitial.txtFolder, frmInitial.txtServer, frmInitial.chkTrusted, frmInitial.txtUsername, frmInitial.txtPassword
Do While Not objRsPackageNames.EOF
ScriptDTSPackage2 objRsPackageNames("Name"), sPath, sServerName, iTrusted, sUserName, sPassword
objRsPackageNames.MoveNext
Loop
Set objRsPackageNames = Nothing
Set objCmd = Nothing
Set objCon = Nothing
End Sub
Private Sub ScriptDTSPackage2(sPackageName, sFolder, sServer, iTrusted, sUID, sPWD)
Dim objFileScript
Dim objFStream
Dim objDTSPackage
Dim objDTSTask
Dim objDTSConnection
Dim objDTSTransformation
Dim objDTSDataPumpTask
Dim objDTSGlobalVariable
Dim objDTSCustomTask
Dim objDTSProperty
Dim objDTSDynamicPropertiesTask
Dim objDTSDynamicPropertiesTaskAssignment
Dim i
Dim s1
Dim s2
Set objFileScript = CreateObject("Scripting.FileSystemObject")
Set objFStream = objFileScript.CreateTextFile(sFolder & sPackageName & "_properties.txt")
' load package
Set objDTSPackage = CreateObject("DTS.Package2")
If iTrusted = "Y" Then
objDTSPackage.LoadFromSQLServer sServer, , , 256, , , , sPackageName
Else
objDTSPackage.LoadFromSQLServer sServer, sUID, sPWD, , , , , sPackageName
End If
' Global variables
objFStream.WriteLine "************************"
objFStream.WriteLine "Global Variables"
objFStream.WriteLine "************************"
For Each objDTSGlobalVariable In objDTSPackage.GlobalVariables
objFStream.WriteLine "<" & objDTSGlobalVariable.name & "=" & objDTSGlobalVariable.value & ">"
Next
' connections
objFStream.WriteBlankLines 2
objFStream.WriteLine "************************"
objFStream.WriteLine "Connections"
objFStream.WriteLine "************************"
For Each objDTSConnection In objDTSPackage.Connections
objFStream.WriteLine "<ID=" & objDTSConnection.ID & ">" & "<name=" & objDTSConnection.Name & ">" & "<Source=" & objDTSConnection.DataSource & ">" & "<ProviderID=" & objDTSConnection.ProviderID & ">"
Next
' tasks
objFStream.WriteBlankLines 2
objFStream.WriteLine "************************"
objFStream.WriteLine "Tasks"
objFStream.WriteLine "************************"
For Each objDTSTask In objDTSPackage.Tasks
objFStream.WriteLine "<type=" & objDTSTask.CustomTaskID & ">" & "<name=" & objDTSTask.Name & ">" & "<Description=" & objDTSTask.Description & ">"
' executesql task
If objDTSTask.CustomTaskID = "DTSExecuteSQLTask" Then
objFStream.WriteLine "<sql statement>"
objFStream.WriteLine objDTSTask.Properties("SQLStatement")
objFStream.WriteLine "<sql statement end>"
' datapump task
ElseIf objDTSTask.CustomTaskID = "DTSDataPumpTask" Then
objFStream.WriteLine "<SourceObjectName=" & objDTSTask.Properties("SourceObjectName") & ">" & "<SourceConnectionID=" & objDTSTask.Properties("SourceConnectionID") & ">"
If objDTSTask.Properties("SourceSQLStatement") <> "" Then
objFStream.WriteLine "<source sql statement>"
objFStream.WriteLine objDTSTask.Properties("SourceSQLStatement")
objFStream.WriteLine "<source sql statement end>"
End If
objFStream.WriteLine "<DestinationObjectName=" & objDTSTask.Properties("DestinationObjectName") & ">" & "<DestinationConnectionID=" & objDTSTask.Properties("DestinationConnectionID") & ">"
Set objDTSDataPumpTask = objDTSTask.CustomTask
objFStream.WriteLine "<transformations=" & ">"
For Each objDTSTransformation In objDTSDataPumpTask.Transformations
For i = 1 To objDTSTransformation.DestinationColumns.Count
objFStream.WriteLine objDTSTask.Properties("SourceObjectName") & "." & objDTSTransformation.SourceColumns(i).Name & " --> " & objDTSTask.Properties("DestinationObjectName") & "." & objDTSTransformation.DestinationColumns(i).Name
Next
Next
objFStream.WriteLine "<transformations=" & " end>"
' dynamic proprties task
ElseIf objDTSTask.CustomTaskID = "DTSDynamicPropertiesTask" Then
Set objDTSDynamicPropertiesTask = objDTSTask.CustomTask
For Each objDTSDynamicPropertiesTaskAssignment In objDTSDynamicPropertiesTask.Assignments
If objDTSDynamicPropertiesTaskAssignment.SourceType = 0 Then
s1 = "<INIFile=" & objDTSDynamicPropertiesTaskAssignment.SourceIniFileFileName & ">" & "<key=" & objDTSDynamicPropertiesTaskAssignment.SourceIniFileSection & "." & objDTSDynamicPropertiesTaskAssignment.SourceIniFileKey & ">"
End If
s2 = " --> " & "<" & objDTSDynamicPropertiesTaskAssignment.DestinationPropertyID & ">"
objFStream.WriteLine s1 & s2
Next
' Activex script task
ElseIf objDTSTask.CustomTaskID = "DTSActiveScriptTask" Then
objFStream.WriteLine "<ActiveXScript>"
objFStream.WriteLine objDTSTask.Properties("ActiveXScript")
objFStream.WriteLine "<ActiveXScript end>"
' Creae Proecss task
ElseIf objDTSTask.CustomTaskID = "DTSCreateProcessTask" Then
objFStream.WriteLine "<ProcessCommandLine>"
objFStream.WriteLine objDTSTask.Properties("ProcessCommandLine")
objFStream.WriteLine "<ProcessCommandLine end>"
' Send Mail task
ElseIf objDTSTask.CustomTaskID = "DTSSendMailTask" Then
Set objDTSCustomTask = objDTSTask.CustomTask
For Each objDTSProperty In objDTSCustomTask.Properties
objFStream.WriteLine objDTSProperty.name & "=" & objDTSProperty.value
Next
' FTP task
ElseIf objDTSTask.CustomTaskID = "DTSFTPTask" Then
For Each objDTSProperty In objDTSTask.Properties
objFStream.WriteLine objDTSProperty.name & "=" & objDTSProperty.value
Next
' Trasnfer Objects task
ElseIf objDTSTask.CustomTaskID = "DTSTransferObjectsTask" Then
Set objDTSCustomTask = objDTSTask.CustomTask
For Each objDTSProperty In objDTSCustomTask.Properties
objFStream.WriteLine objDTSProperty.name & "=" & objDTSProperty.value
Next
Else
objFStream.WriteLine "**********************" & objDTSTask.Name & " task name not catered for **********************"
End If
objFStream.WriteBlankLines 2
Next
objFStream.Close
Set objFStream = Nothing
Set objDTSPackage = Nothing
End Sub
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply