SSIS包作业执行完成后如何查看结果?

发布于 2024-11-09 14:34:44 字数 259 浏览 3 评论 0原文

我有一个 SSIS 包,它将数据导入 SQL Server 2008 数据库。我已经在 SQL Server 代理中设置了计划作业来运行该包。当我查看历史记录时,我只能看到作业是否运行成功。除此之外我看不到其他消息。

我想知道每当执行作业时会导入多少条记录。我怎样才能监控它?我应该使用 SSIS 包中的附加组件还是在 SQL Server 代理作业设置中设置一些配置?

我在 SQL Server 代理作业设置中找到了一些日志记录工具,但我不确定它是否可以满足我的要求。

I have an SSIS package which imports the data into the SQL Server 2008 database. I have set up the schedule job in the SQL Server Agent to run that package. When I check the history, I could only see whether the job ran successfully or not. I could not see other messages apart from that.

I would like to know how many records are imported whenever the job is executed. How can I monitor that? Should I use the additional components in SSIS package or set some configurations in SQL Server Agent Job Setup?

I found some logging facilities in SQL Server Agent Job Setup but I am not sure it can fulfill my requirements or not.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

悍妇囚夫 2024-11-16 14:35:36

如果您已将该包部署到数据库的集成服务目录(而不是从文件系统加载它),您可以轻松获得详细的报告。

在 SQL Server Management Studio 中打开目录节点,右键单击包名称,选择“报表”|“报表”。标准报告|所有执行并查看有关作业及其子组件的每个步骤的详细信息,包括导入的记录。

If you have deployed the package to the database's Integration Services Catalog (rather than load it from a file system) you can easily get detailed reporting.

Open the catalog node in SQL Server Management Studio, right click the Package name, select Reports | Standard Reports | All Executions and see details about every step of the job and its subcomponents, including records imported.

予囚 2024-11-16 14:35:31

当 SQL Server 作业历史记录不显示 SSIS 包的输出时,还有另一种方法:使用 DTEXEC 命令行。

(好处:这种方法将作业的输出放在支持它的其他人期望找到的地方:在作业历史记录中。
大包的缺点:如果你有一个很长的SSIS包,有很多任务或组件,还有很多输出,那么作业历史记录会将包输出分成很多行作业历史记录,从而采用前面答案中的方法——日志记录到表中——更易于阅读。)

要在作业的查看历史记录中显示 SSIS 包输出:
(1) 将作业步骤从类型“SQL Server Integration Services Package”更改为“操作系统 (CmdExec)”,
(2) 使用DTEXEC命令行,执行包。

命令行示例:

DTExec /DTS "\MSDB\myPkgName" /DECRYPT pkgPass /MAXCONCURRENT " -1 " /CHECKPOINTING OFF 

请注意,如果 SSIS 包需要 32 位 执行(例如,导出到 Excel 时为 true),则通过完全限定来使用“Program Files (x86)”中的 DTEXEC 实用程序它。例如,SQL Server 应用程序安装在“E:”驱动器上,并且使用 SQL Server 2014:

"E:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\DTExec.exe" /DTS "\MSDB\myPkgName" /DECRYPT pkgPass /MAXCONCURRENT " -1 " /CHECKPOINTING OFF

如果您的 SSIS 包位于文件系统中(作为“.dtsx”文件),则替换“/DTS”与“/文件”。

如果您的 SSIS 包放置在 SSISDB 中(使用从 SQL Server 2012 开始提供的“项目部署模型”,而不是旧的“包部署模型”),则将“/DTS”替换为“/ISSERVER”。

接下来,进入作业步骤的“高级”页面,并确保选中“在历史记录中包含步骤输出”框。

最后,考虑您的作业步骤的“运行方式”:如果您的作业步骤“运行方式”已设置为“SQL Server Integration Services Package”类型的作业步骤上的代理,则您已将该代理设置为对子系统有效SQL Server 集成服务包”。现在,要执行上述命令行,请检查代理的属性,并确保它对于子系统“操作系统 (CmdExec)”也处于活动状态。

MSDN 参考:Sql 代理历史记录上的 SSIS 输出

Here's another approach for when SQL Server job history is not showing output from SSIS packages: use DTEXEC command lines.

(Upside: this approach puts the job's output where anyone else supporting it would expect to find it: in job history.
Downside for big packages: if you have a long SSIS package, with lots of tasks or components, and lots of output, then the job history will split package output into many lines of job history, making the approach in the previous answer--logging to a table--easier to read.)

To show SSIS package output in the job's View History:
(1) Change the job steps from type "SQL Server Integration Services Package", to "Operating system (CmdExec)",
(2) Use DTEXEC command lines, to execute the packages.

Example of command line:

DTExec /DTS "\MSDB\myPkgName" /DECRYPT pkgPass /MAXCONCURRENT " -1 " /CHECKPOINTING OFF 

Note that if the SSIS package requires 32-BIT execution (true for exporting to Excel, for example), then use the DTEXEC utility in "Program Files (x86)" by fully qualifying it. Example, where the SQL Server application was installed on an "E:" drive, and where SQL Server 2014 is being used:

"E:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\DTExec.exe" /DTS "\MSDB\myPkgName" /DECRYPT pkgPass /MAXCONCURRENT " -1 " /CHECKPOINTING OFF

If your SSIS packages are in the file system (as ".dtsx" files), then replace "/DTS" with "/FILE".

If your SSIS packages were placed in SSISDB (using the "project deployment model", which is available starting with SQL Server 2012, instead of the older "package deployment model"), then replace "/DTS" with "/ISSERVER".

Next, go into the job step's "Advanced" page, and make sure that the box is checked for "Include step output in history".

Lastly, consider your job step's "Run as": if your job steps "Run as" were already set to a proxy, on job steps of type "SQL Server Integration Services Package", then you already made that proxy active to the subsystem "SQL Server Integration Services Package". Now, to do command lines like the above, check the proxy's properties, and make sure it is also active to the subsystem "Operating system (CmdExec)".

MSDN reference: SSIS Output on Sql Agent history

您的好友蓝忘机已上羡 2024-11-16 14:35:26

使用以下过程获取带有执行 ID 的 SSIS 错误

CREATE PROCEDURE [dbo].[get_ssis_status] @EXECUTION_ID INT\n
AS
BEGIN
  SELECT o.operation_id EXECUTION_ID
    ,convert(datetimeoffset,OM.message_time,109) TIME
    ,D.message_source_desc ERROR_SOURCE
    ,OM.message ERROR_MESSAGE
    ,CASE ex.STATUS
        WHEN 4 THEN 'Package Failed'
        WHEN 7 THEN CASE EM.message_type 
            WHEN 120 THEN 'package failed' 
            WHEN 130 THEN 'package failed' ELSE 'Package Succeed'END
        END AS STATUS
FROM SSISDB.CATALOG.operation_messages AS OM
INNER JOIN SSISDB.CATALOG.operations AS O ON O.operation_id = OM.operation_id
INNER JOIN SSISDB.CATALOG.executions AS EX ON o.operation_id = ex.execution_id
INNER JOIN (VALUES (- 1,'Unknown'),(120,'Error'),(110,'Warning'),(130,'TaskFailed')) EM(message_type, message_desc) ON EM.message_type = OM.message_type
INNER JOIN (VALUES 
 (10,'Entry APIs, such as T-SQL and CLR Stored procedures')
,(20,'External process used to run package (ISServerExec.exe)')
,(30,'Package-level objects')
,(40,'Control Flow tasks')
,(50,'Control Flow containers')
,(60,'Data Flow task')
    ) D(message_source_type, message_source_desc) ON D.message_source_type = OM.message_source_type
WHERE ex.execution_id = @EXECUTION_ID
AND OM.message_type IN (120,130,-1);
END

use the below procedure for getting SSIS errors with execution id

CREATE PROCEDURE [dbo].[get_ssis_status] @EXECUTION_ID INT\n
AS
BEGIN
  SELECT o.operation_id EXECUTION_ID
    ,convert(datetimeoffset,OM.message_time,109) TIME
    ,D.message_source_desc ERROR_SOURCE
    ,OM.message ERROR_MESSAGE
    ,CASE ex.STATUS
        WHEN 4 THEN 'Package Failed'
        WHEN 7 THEN CASE EM.message_type 
            WHEN 120 THEN 'package failed' 
            WHEN 130 THEN 'package failed' ELSE 'Package Succeed'END
        END AS STATUS
FROM SSISDB.CATALOG.operation_messages AS OM
INNER JOIN SSISDB.CATALOG.operations AS O ON O.operation_id = OM.operation_id
INNER JOIN SSISDB.CATALOG.executions AS EX ON o.operation_id = ex.execution_id
INNER JOIN (VALUES (- 1,'Unknown'),(120,'Error'),(110,'Warning'),(130,'TaskFailed')) EM(message_type, message_desc) ON EM.message_type = OM.message_type
INNER JOIN (VALUES 
 (10,'Entry APIs, such as T-SQL and CLR Stored procedures')
,(20,'External process used to run package (ISServerExec.exe)')
,(30,'Package-level objects')
,(40,'Control Flow tasks')
,(50,'Control Flow containers')
,(60,'Data Flow task')
    ) D(message_source_type, message_source_desc) ON D.message_source_type = OM.message_source_type
WHERE ex.execution_id = @EXECUTION_ID
AND OM.message_type IN (120,130,-1);
END
郁金香雨 2024-11-16 14:35:20

如果您只是想了解正在处理的列,而对进一步使用的信息不感兴趣,一种可能的选择是使用 SSIS 日志记录功能。以下是它如何用于数据流任务。

  1. 单击 SSIS 包。
  2. 在菜单上,选择“SSIS -->”日志记录...
  3. 在“配置 SSIS 日志:”对话框中,选择提供程序类型并单击“添加”。我选择 SQL Server 作为本示例。选中名称复选框并在配置列下提供数据源。这里 SQLServer 是连接管理器的名称。 SSIS 将在您选择的数据库中创建一个名为dbo.sysssislog 的表和存储过程dbo.sp_ssis_addlogentry。请参阅下面的屏幕截图#1
  4. 如果需要处理行,请选中“OnInformation”复选框。在示例中,包执行成功,因此在 OnInformation 下找到日志记录。您可能需要根据您的要求微调此事件选择。请参阅下面的屏幕截图#2
  5. 以下是数据流任务中的示例包执行。请参阅下面的屏幕截图#3
  6. 以下是日志表 dbo.sysssislog 的示例输出。我只显示了 idmessage 列。表中还有许多其他列。在查询中,我仅过滤名为“Package1”的包和事件“OnInformation”的输出。您可以注意到 ID 为 7、14 和 15 的记录包含已处理的行。请参阅下面的屏幕截图#4

希望有帮助。

屏幕截图 #1

Logging

屏幕截图 #2

事件

屏幕截图#3

执行

屏幕截图 #4

数据

If you are just interested in knowing the columns being processed and not interested with the info for further use, one possible option is making use of the SSIS logging feature. Here is how it works for data flow tasks.

  1. Click on the SSIS package.
  2. On the menus, select SSIS --> Logging...
  3. On the Configure SSIS Logs: dialog, select the provider type and click Add. I have chosen SQL Server for this example. Check the Name checkbox and provide the data source under Configuration column. Here SQLServer is the name of the connection manager. SSIS will create a table named dbo.sysssislog and stored procedure dbo.sp_ssis_addlogentry in the database that you selected. Refer screenshot #1 below.
  4. If you need the rows processed, select the checkbox OnInformation. Here in the example, the package executed successfully so the log records were found under OnInformation. You may need to fine tune this event selection according to your requirements. Refer screenshot #2 below.
  5. Here is a sample package execution within data flow task. Refer screenshot #3 below.
  6. Here is a sample output of the log table dbo.sysssislog. I have only displayed the columns id and message. There are many other columns in the table. In the query, I am filtering the output only for the package named 'Package1' and the event 'OnInformation'. You can notice that records with ids 7, 14 and 15 contain the rows processed. Refer screenshot #4 below.

Hope that helps.

Screenshot #1:

Logging

Screenshot #2:

Events

Screenshot #3:

Execution

Screenshot #4:

Data

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文