比林克的好答案。除了那个答案(或者更确切地说是充实“检查对象模型并查看配置的内容”部分),我在任何包的开头运行一个脚本,将所有连接管理器连接字符串的值添加到输出窗口,后跟每个管理器的连接字符串表达式。此外,它循环遍历脚本中指定使用的所有变量并输出值。在生产中不太有用,但在开发/测试时非常有用。
只需将脚本任务添加到包流的开头,指定要调试的任何变量,然后将以下代码添加到脚本中:
'Report number of connections
Dts.Events.FireInformation(99, "debug", "number of connections = " & Dts.Connections.Count, "", 0, True)
'Loop through connection collection
For Each cConnection As Microsoft.SqlServer.Dts.Runtime.ConnectionManager In Dts.Connections
'Report connection string value
Try
Dts.Events.FireInformation(99, "debug", "connection """ & cConnection.Name & """ value = " & cConnection.ConnectionString, "", 0, True)
Catch
End Try
'Report connection string expression
Try
Dts.Events.FireInformation(99, "debug", "connection """ & cConnection.Name & """ constring expression = " & cConnection.GetExpression("ConnectionString"), "", 0, True)
Catch
End Try
Next
'Report number of variables
Dts.Events.FireInformation(99, "debug", "Number of Variables = " & Dts.Variables.Count, "", 0, True)
'Loop through variables collection
For Each vVariable As Microsoft.SqlServer.Dts.Runtime.Variable In Dts.Variables
'Report variable value
Try
Dts.Events.FireInformation(99, "debug", "Variable """ & vVariable.Name & """ value = " & vVariable.Value, "", 0, True)
Catch
End Try
Next