Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SQLCode
Posting Yak Master
143 Posts |
Posted - 2004-03-31 : 13:44:37
|
| Hi,I have to analyze all DTS packages of a few servers.Is it possible to document the packages with the workflow and properties, in any relatively quick method?Right now I am opening the packages and documenting each step manually.I have a few very huge packages that are used to build a warehouse.Please help.TIA |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-03-31 : 14:37:09
|
| Try thisIt will give all the connections and transformation to text files in a folder.Any tasks not included will be marked as "not catered for" - search for those and add them.I think this version is for an activex script in a dts package but will probably work from VB too.Private Sub ScriptDTSPackage2(sPackageName, sFolder, sServer, iTrusted, sUID, sPWD)Dim objFileScriptDim objFStreamDim objDTSPackageDim objDTSTaskDim objDTSConnectionDim objDTSTransformationDim objDTSDataPumpTaskDim objDTSDynamicPropertiesTaskDim objDTSDynamicPropertiesTaskAssignmentDim iDim s1Dim s2Set objFileScript = CreateObject("Scripting.FileSystemObject")Set objFStream = objFileScript.CreateTextFile(sFolder & sPackageName & ".txt")' load packageSet objDTSPackage = CreateObject("DTS.Package2")If iTrusted = 1 ThenobjDTSPackage.LoadFromSQLServer sServer, , , 256, , , , sPackageNameElseobjDTSPackage.LoadFromSQLServer sServer, sUID, sPWD, , , , , sPackageNameEnd If' connectionsobjFStream.WriteLine "************************"objFStream.WriteLine "Connections"objFStream.WriteLine "************************"For Each objDTSConnection In objDTSPackage.ConnectionsobjFStream.WriteLine "<ID=" & objDTSConnection.ID & ">" & "<name=" & objDTSConnection.Name & ">" & "<Source=" & objDTSConnection.DataSource & ">" & "<ProviderID=" & objDTSConnection.ProviderID & ">"Next' tasksobjFStream.WriteBlankLines 2objFStream.WriteLine "************************"objFStream.WriteLine "Tasks"objFStream.WriteLine "************************"For Each objDTSTask In objDTSPackage.TasksobjFStream.WriteLine "<type=" & objDTSTask.CustomTaskID & ">" & "<name=" & objDTSTask.Name & ">" & "<Description=" & objDTSTask.Description & ">"' executesql taskIf objDTSTask.CustomTaskID = "DTSExecuteSQLTask" ThenobjFStream.WriteLine "<sql statement>"objFStream.WriteLine objDTSTask.Properties("SQLStatement")objFStream.WriteLine "<sql statement end>"' datapump taskElseIf objDTSTask.CustomTaskID = "DTSDataPumpTask" ThenobjFStream.WriteLine "<SourceObjectName=" & objDTSTask.Properties("SourceObjectName") & ">" & "<SourceConnectionID=" & objDTSTask.Properties("SourceConnectionID") & ">"If objDTSTask.Properties("SourceSQLStatement") <> "" ThenobjFStream.WriteLine "<source sql statement>"objFStream.WriteLine objDTSTask.Properties("SourceSQLStatement")objFStream.WriteLine "<source sql statement end>"End IfobjFStream.WriteLine "<DestinationObjectName=" & objDTSTask.Properties("DestinationObjectName") & ">" & "<DestinationConnectionID=" & objDTSTask.Properties("DestinationConnectionID") & ">"Set objDTSDataPumpTask = objDTSTask.CustomTaskobjFStream.WriteLine "<transformations=" & ">"For Each objDTSTransformation In objDTSDataPumpTask.TransformationsFor i = 1 To objDTSTransformation.DestinationColumns.CountobjFStream.WriteLine objDTSTask.Properties("SourceObjectName") & "." & objDTSTransformation.SourceColumns(i).Name & " --> " & objDTSTask.Properties("DestinationObjectName") & "." & objDTSTransformation.DestinationColumns(i).NameNextNextobjFStream.WriteLine "<transformations=" & " end>"' dynamic proprties taskElseIf objDTSTask.CustomTaskID = "DTSDynamicPropertiesTask" ThenSet objDTSDynamicPropertiesTask = objDTSTask.CustomTaskFor Each objDTSDynamicPropertiesTaskAssignment In objDTSDynamicPropertiesTask.AssignmentsIf objDTSDynamicPropertiesTaskAssignment.SourceType = 0 Thens1 = "<INIFile=" & objDTSDynamicPropertiesTaskAssignment.SourceIniFileFileName & ">" & "<key=" & objDTSDynamicPropertiesTaskAssignment.SourceIniFileSection & "." & objDTSDynamicPropertiesTaskAssignment.SourceIniFileKey & ">"End Ifs2 = " --> " & "<" & objDTSDynamicPropertiesTaskAssignment.DestinationPropertyID & ">"objFStream.WriteLine s1 & s2NextElseIf objDTSTask.CustomTaskID = "DTSActiveScriptTask" ThenobjFStream.WriteLine "<ActiveXScript>"objFStream.WriteLine objDTSTask.Properties("ActiveXScript")objFStream.WriteLine "<ActiveXScript end>"ElseIf objDTSTask.CustomTaskID = "DTSCreateProcessTask" ThenobjFStream.WriteLine "<ProcessCommandLine>"objFStream.WriteLine objDTSTask.Properties("ProcessCommandLine")objFStream.WriteLine "<ProcessCommandLine end>"ElseobjFStream.WriteLine "**********************" & objDTSTask.Name & " task name not catered for **********************"End IfobjFStream.WriteBlankLines 2NextobjFStream.CloseSet objFStream = NothingSet objDTSPackage = NothingEnd SubPrivate Sub ScriptDTSPackages(sServerName, sUserName, sPassword, sPath)Dim objConDim objCmdDim objRsPackageNamesSet objCon = CreateObject("ADODB.Connection")objCon.ConnectionString = "Provider=sqloledb;" & _"Data Source=" & sServerName & ";" & _"User Id=" & sUserName & ";" & ";" & _"Password=" & sPassword & ";" & _"Initial Catalog=" & "msdb"objCon.CursorLocation = 3 'adUseClientobjCon.OpenSet objCmd = CreateObject("ADODB.Command")objCmd.ActiveConnection = objConobjCmd.CommandType = 1 'adCmdTextobjCmd.CommandText = "select distinct name from sysdtspackages order by name"Set objRsPackageNames = CreateObject("ADODB.Recordset")Set objRsPackageNames = objCmd.ExecuteDo While Not objRsPackageNames.EOFScriptDTSPackage2 objRsPackageNames("Name"), sPath, sServerName, 0, sUserName, sPasswordobjRsPackageNames.MoveNextLoopSet objRsPackageNames = NothingSet objCmd = NothingSet objCon = NothingEnd Sub==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-03-31 : 14:39:05
|
| Doesn't include the workflow - maybe I'll include it sometime.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
SQLCode
Posting Yak Master
143 Posts |
Posted - 2004-03-31 : 14:50:28
|
| Thanks Nigel! Appreciate your post. I keep checking your site also quite often.I do not have VB and do not know how to use your function. Would you pls. guide me?TIA |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-03-31 : 14:59:19
|
| It's not on my site yet.Put in into an activex script in a dts packageAdd a call toSub ScriptDTSPackages(sServerName, sUserName, sPassword, sPath)with the relevent parameters and it will script all packages on that server to the path given.This is set to call ScriptDTSPackage2 with sql server security you will have to change the call if you want it to be trusted.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|