简体   繁体   中英

How to get actual execution time of SSIS package while using DTEXEC.EXE Command Line Utility

I am executing one SSIS package using DTEXEC.EXE as below

C:\\Program Files\\Microsoft SQL Server\\140\\DTS\\Binn>DTExec.exe /Server localhost /ISServer "\\MyServer\\mypackage.dtsx"

After executing the command it is displaying below details.

Started:  3:28:09 PM
Execution ID: 41165.
To view the details for the execution, right-click on the Integration Services Catalog, and open the [All Executions] report
Started:  3:28:09 PM
Finished: 3:28:09 PM
Elapsed:  0.172 seconds

Actual execution time of the package was 20 minutes but the 'Elapsed time shows as 0.172 seconds. Are there any option to get the actual execution time while running the package using the command line?

Thanks in advance

When you run SSIS packages from DTEXEC, they will run in synchronous execution mode. Unless , you ask that they be run from the SSISDB. Then you need to add an additional parameter to your DTEXEC call of /Par "$ServerOption::SYNCHRONIZED(Boolean)";True

I created a package with an explict waitfor delay of 15 seconds and ran it twice from my machine.

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

The first, default execution, takes no time because it hands off responsibility to the SQL Server itself. The second forces us to get messages in realtime and thus, 15 seconds + setup time

What is displayed above is the actual time to load and execute the package. The runtime of the package is what you are looking for.

It is common practice to write lines to an audit table, you start your package by writing the package id & currenttime, name and whatelse you want to the table (error messages etc.)

At the end of the packge you update the row in the DB with an endtime.

You can query this table and compare start & endtimes to find the total time to run the package.

An example of audit table we commonly use here;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM