如何在使用DTEXEC.EXE命令行实用工具时获取SSIS包的实际执行时间

时间:2018-11-28 20:40:11

标签: sql-server ssis sql-server-2017

我正在使用DTEXEC.EXE如下执行一个SSIS程序包

  

C:\ Program Files \ Microsoft SQL Server \ 140 \ DTS \ Binn> DTExec.exe / Server本地主机/ ISServer“ \ MyServer \ mypackage.dtsx”

执行命令后,它会显示在下面的详细信息中。

// call this in your root view controller that has the inputAccessoryView currently displayed
let addViewController = YourViewControllerClass()
modalViewController.inputAccessoryView = self.inputAccessoryView
self.present(addViewController, animated: true, completion: nil))

该软件包的实际执行时间为20分钟,但“经过时间显示为0.172秒。使用命令行运行程序包时,是否有任何选项可以获取实际的执行时间?

预先感谢

2 个答案:

答案 0 :(得分:1)

当您从DTEXEC运行SSIS程序包时,它们将在同步执行模式下运行。 除非,否则您要求从SSISDB运行它们。然后,您需要在DTEXEC调用/Par "$ServerOption::SYNCHRONIZED(Boolean)";True

中添加一个附加参数。

我创建了一个明显的等待延迟为15秒的程序包,并从我的机器上运行了两次。

C:\Users\billinkc>dtexec /server .\dev2017 /ISServer "\ssisdb\So\JustWait\Package.dtsx"
Microsoft (R) SQL Server Execute Package Utility
Version 14.0.3037.1 for 32-bit
Copyright (C) 2017 Microsoft. All rights reserved.

Started:  7:41:06 AM
Execution ID: 161421.
To view the details for the execution, right-click on the Integration Services Catalog, and open the [All Executions] report
Started:  7:41:06 AM
Finished: 7:41:07 AM
Elapsed:  0.141 seconds

C:\Users\billinkc>dtexec /server .\dev2017 /ISServer "\ssisdb\So\JustWait\Package.dtsx" /Par "$ServerOption::SYNCHRONIZED(Boolean)";True
Microsoft (R) SQL Server Execute Package Utility
Version 14.0.3037.1 for 32-bit
Copyright (C) 2017 Microsoft. All rights reserved.

Started:  7:41:12 AM
Execution ID: 161422.
To view the details for the execution, right-click on the Integration Services Catalog, and open the [All Executions] report
Started:  7:41:12 AM
Finished: 7:41:30 AM
Elapsed:  18.39 seconds

第一个默认执行无需花费时间,因为它将责任移交给了SQL Server本身。第二个强迫我们实时获取消息,因此需要15秒+设置时间

答案 1 :(得分:0)

上面显示的是加载和执行程序包的实际时间。该包的运行时就是您要寻找的。

通常的做法是将行写到审计表中,然后通过在表中写入程序包ID和当前时间,名称和其他名称(错误消息等)来启动程序包。

在打包结束时,使用结束时间更新数据库中的行。

您可以查询该表并比较开始时间和结束时间,以找到运行程序包的总时间。

我们通常在此处使用的审计表示例;

USE [database]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[dim_audit](
    [AuditKey] [int] IDENTITY(1,1) NOT NULL,
    [ParentAuditKey] [int] NOT NULL,
    [TableName] [nvarchar](50) NOT NULL,
    [PkgName] [nvarchar](50) NOT NULL,
    [PkgGUID] [uniqueidentifier] NULL,
    [PkgVersionGUID] [uniqueidentifier] NULL,
    [PkgVersion] [nvarchar](50) NULL,
    [ExecStartDT] [datetime] NOT NULL,
    [ExecStopDT] [datetime] NULL,
    [ExecutionInstanceGUID] [uniqueidentifier] NULL,
    [ExtractRowCnt] [bigint] NULL,
    [InsertRowCnt] [bigint] NULL,
    [UpdateRowCnt] [bigint] NULL,
    [DeleteRowCnt] [bigint] NULL,
    [TableInitialRowCnt] [bigint] NULL,
    [TableFinalRowCnt] [bigint] NULL,
    [TableMaxSurrogateKey] [bigint] NULL,
    [SuccessfulProcessingInd] [nchar](1) NOT NULL,
 CONSTRAINT [PK_dim_audit] PRIMARY KEY CLUSTERED 
(
    [AuditKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO