我使用包含一个软件包的2012部署模型创建了一个SSIS项目。在该程序包中,我添加了一个OLE DB连接管理器,将其指向tempdb,并将脚本任务放到画布上。我还使用该OLE DB连接管理器打开了显式日志记录并捕获了该OnInformation
事件。
SCR火灾信息
我将脚本任务配置为具有两个参数:System::ExecutionInstanceGUID
并且System::ServerExecutionID
我承认,在玛丽安回答之前,我没有注意到第二个变量。在任务内部,我引发2个Information事件,以便获取记录的值。这应该记录到显式表(dbo.sysssislog)和“免费”记录(catalog.operation_messages)中。
public void Main()
{
bool fireAgain = true;
string description = string.Empty;
string variable = string.Empty;
string value = string.Empty;
variable = "System::ServerExecutionID";
value = Dts.Variables[variable].Value.ToString();
description = string.Format("{0}: {1}", variable, value);
Dts.Events.FireInformation(0, "Reporting", description, string.Empty, 0, ref fireAgain);
variable = "System::ExecutionInstanceGUID";
value = Dts.Variables[variable].Value.ToString();
description = string.Format("{0}: {1}", variable, value);
Dts.Events.FireInformation(0, "Reporting", description, string.Empty, 0, ref fireAgain);
Dts.TaskResult = (int)ScriptResults.Success;
}
部署并执行
然后,我将项目部署到服务器上并执行它。
我打开了操作报告,然后单击SCR Fire info
任务详细信息。
红色圆圈表示我们正在按预期方式查看操作8的详细信息。突出显示的行是使OnInformation
这两个系统变量的值冒泡的事件。同样符合预期,其值System::ServerExecutionID
与报告中的值匹配。的值System::ExecutionInstanceGUID
一如既往地无意义,但存在{3F515780-8062-40AA-B9EC-C320CBAC5EFD}。
绑在一起
我现在有两个不同的原木,我想绑在一起。
sysssislog查询
运行此查询将从老式日志表中撤回相关行。
SELECT
L.event
, L.source
, L.message
FROM
dbo.sysssislog AS L
WHERE
L.executionid = '{3F515780-8062-40AA-B9EC-C320CBAC5EFD}'
ORDER BY
L.id ASC;
结果看起来像
event source message
PackageStart ParameterTest Beginning of package execution.
OnInformation SCR Fire info System::ServerExecutionID: 8
OnInformation ParameterTest System::ServerExecutionID: 8
OnInformation SCR Fire info System::ExecutionInstanceGUID: {3F515780-8062-40AA-B9EC-C320CBAC5EFD}
OnInformation ParameterTest System::ExecutionInstanceGUID: {3F515780-8062-40AA-B9EC-C320CBAC5EFD}
PackageEnd ParameterTest End of package execution.
catalog.operation_messages查询
针对SSISDB目录运行此查询将显示上述报告中的所有消息,并确认我可以将值链接message
至operation_id
以及dbo.sysssislog.executionid
SELECT
OM.*
FROM
catalog.operation_messages AS OM
WHERE
OM.operation_id = 8;
这些结果是
operation_message_id operation_id message_time message_type message_source_type message extended_info_id
30 8 2013-04-02 21:02:34.1418917 -05:00 10 30 ParameterTest:Validation has started. NULL
31 8 2013-04-02 21:02:34.1738922 -05:00 10 40 SCR Fire info:Validation has started. NULL
32 8 2013-04-02 21:02:34.1768872 -05:00 20 40 SCR Fire info:Validation is complete. NULL
33 8 2013-04-02 21:02:34.1788903 -05:00 20 30 ParameterTest:Validation is complete. NULL
34 8 2013-04-02 21:02:34.3349188 -05:00 30 30 ParameterTest:Start, 9:02:34 PM. NULL
35 8 2013-04-02 21:02:34.4009253 -05:00 30 40 SCR Fire info:Start, 9:02:34 PM. NULL
36 8 2013-04-02 21:02:34.4009253 -05:00 10 40 SCR Fire info:Validation has started. NULL
37 8 2013-04-02 21:02:34.4019251 -05:00 20 40 SCR Fire info:Validation is complete. NULL
38 8 2013-04-02 21:02:34.4219283 -05:00 70 40 SCR Fire info:Information: System::ServerExecutionID: 8 NULL
39 8 2013-04-02 21:02:34.4259295 -05:00 70 40 SCR Fire info:Information: System::ExecutionInstanceGUID: {3F515780-8062-40AA-B9EC-C320CBAC5EFD} NULL
40 8 2013-04-02 21:02:34.4409316 -05:00 40 40 SCR Fire info:Finished, 9:02:34 PM, Elapsed time: 00:00:00.031. NULL
41 8 2013-04-02 21:02:34.4419388 -05:00 40 30 ParameterTest:Finished, 9:02:34 PM, Elapsed time: 00:00:00.125. NULL
包起来
当在SSISDB目录的上下文之外(也通过SSDT-BI或.ispac的命令行)执行该程序包时,the的值System::ServerExecutionID
将为0。这是有道理的,但是以后的读者可能会使用LEFT OUTER JOIN如果要捕获软件包的所有执行,将sysssislog链接到catalog.operation_messages时。
帽子提示,我衷心的感谢和感谢,这归功于玛丽安(Marian)使我走上了正轨。鉴于可以在摘要日志表中存储GUID(16字节)和bigint(8字节)之间进行选择,这对我来说是毫不费力的:请单调增加大整数。