-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathssis-execution-package-history.sql
98 lines (87 loc) · 2.27 KB
/
ssis-execution-package-history.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
:: PURPOSE
Show execution historical data
:: NOTES
Also show Dataflow destination informations
:: INFO
Author: Davide Mauri
Version: 1.0
*/
USE SSISDB
GO
/*
Configuration
*/
-- Filter data by message source name (use % for no filter)
DECLARE @sourceNameFilter AS nvarchar(max) = '%%';
/*
Implementation
*/
IF (OBJECT_ID('tempdb..#t') IS NOT NULL) DROP TABLE #t;
WITH
ctePRE AS
(
SELECT * FROM catalog.event_messages em
WHERE em.event_name IN ('OnPreExecute')
),
ctePOST AS
(
SELECT * FROM catalog.event_messages em
WHERE em.event_name IN ('OnPostExecute')
)
SELECT
b.operation_id,
from_event_message_id = b.event_message_id,
to_event_message_id = e.event_message_id,
b.package_path,
b.message_source_name,
pre_message_time = b.message_time,
post_message_time = e.message_time,
elapsed_time_min = DATEDIFF(mi, b.message_time, COALESCE(e.message_time, SYSDATETIMEOFFSET()))
INTO
#t
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
INNER JOIN
[catalog].executions e2 ON b.operation_id = e2.execution_id
WHERE
b.package_path = '\Package'
AND
b.message_source_name LIKE @sourceNameFilter
AND
e2.status IN (2,7)
;
SELECT * FROM #t ORDER BY operation_id DESC;
-- Show DataFlow Destination Informations
WITH cte AS
(
SELECT
*,
token_destination_name_start = CHARINDEX(': "', [message]) + 3,
token_destination_name_end = CHARINDEX('" wrote', [message]),
token_rows_start = LEN([message]) - CHARINDEX('e', REVERSE([message]), 1) + 3,
token_rows_end = LEN([message]) - CHARINDEX('r', REVERSE([message]), 1)
FROM
[catalog].[event_messages] em
)
SELECT TOP 100
c.operation_id,
event_message_id,
package_name,
c.message_source_name,
message_time,
--destination_name = SUBSTRING([message], token_destination_name_start, token_destination_name_end - token_destination_name_start),
loaded_rows = SUBSTRING([message], token_rows_start, token_rows_end - token_rows_start),
[message]
FROM
cte as c
INNER JOIN
#t t ON c.operation_id = t.operation_id AND c.event_message_id BETWEEN t.from_event_message_id AND t.to_event_message_id
WHERE
subcomponent_name = 'SSIS.Pipeline'
AND
[message] like '%rows.%'
ORDER BY
c.operation_id desc, message_time DESC