-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathssis-execution-breakdown.sql
75 lines (65 loc) · 1.55 KB
/
ssis-execution-breakdown.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
:: PURPOSE
Show the execution breakdown for a specific execution (operation_id)
:: NOTES
None
:: INFO
Author: Davide Mauri
Version: 1.0
*/
USE SSISDB
GO
/*
Configuration
*/
-- Filter data by execution id (use NULL for no filter)
DECLARE @operation_id AS bigint = 1234;
/*
Implementation
*/
WITH
ctePRE AS
(
SELECT * FROM catalog.event_messages em
WHERE em.event_name IN ('OnPreExecute') and operation_id = @operation_id
),
ctePOST AS
(
SELECT * FROM catalog.event_messages em
WHERE em.event_name IN ('OnPostExecute') and operation_id = @operation_id
)
SELECT
b.operation_id,
e2.status,
status_desc = CASE e2.status
WHEN 1 THEN 'Created'
WHEN 2 THEN 'Running'
WHEN 3 THEN 'Cancelled'
WHEN 4 THEN 'Failed'
WHEN 5 THEN 'Pending'
WHEN 6 THEN 'Ended Unexpectedly'
WHEN 7 THEN 'Succeeded'
WHEN 8 THEN 'Stopping'
WHEN 9 THEN 'Completed'
END,
b.event_message_id,
--b.package_path,
b.execution_path,
b.message_source_name,
pre_message_time = b.message_time,
post_message_time = e.message_time,
DATEDIFF(mi, b.message_time, COALESCE(e.message_time, SYSDATETIMEOFFSET()))
FROM
ctePRE b
LEFT OUTER JOIN
ctePOST e ON b.operation_id = e.operation_id AND b.package_name = e.package_name AND b.message_source_id = e.message_source_id and b.execution_path = e.execution_path
INNER JOIN
[catalog].executions e2 ON b.operation_id = e2.execution_id
WHERE
b.package_path = '\Package'
AND
-- b.message_source_name = @source_name
b.operation_id = @operation_id
ORDER BY
b.event_message_id desc
;