forked from yorek/ssis-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssis-execution-status.sql
179 lines (162 loc) · 3.35 KB
/
ssis-execution-status.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
:: PURPOSE
Show the latest executed packages
:: NOTES
For the *first* package in the list, also show
. Performance of last 15 successful executions
. Error messages
. Duplicate lookup messages
. Memory allocation warnings
. Low virtual memory warnings
:: INFO
Author: Davide Mauri
Version: 1.0
*/
USE SSISDB
GO
/*
Configuration
*/
-- Filter data by project name (use % for no filter)
DECLARE @projectNamePattern NVARCHAR(100) = '%'
-- Filter data by package name (use % for no filter)
DECLARE @packageNamePattern NVARCHAR(100) = '%'
-- Filter data by execution id (use NULL for no filter)
DECLARE @executionIdFilter BIGINT = NULL
/*
Implementation
*/
-- Show last 15 executions
SELECT TOP 15
e.execution_id,
e.project_name,
e.package_name,
e.project_lsn,
e.status,
status_desc = CASE e.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,
e.start_time,
e.end_time,
elapsed_time_min = datediff(mi, e.start_time, e.end_time)
FROM
catalog.executions e
WHERE
e.project_name LIKE @projectNamePattern
AND
e.package_name LIKE @packageNamePattern
AND
e.execution_id = ISNULL(@executionIdFilter, e.execution_id)
ORDER BY
e.execution_id DESC
OPTION
(RECOMPILE)
;
-- Get detailed information for the first package in the list
DECLARE @executionId BIGINT, @packageName NVARCHAR(1000)
SELECT
TOP 1 @executionId = e.execution_id, @packageName = e.package_name
FROM
[catalog].executions e
WHERE
e.project_name LIKE @projectNamePattern
AND
e.package_name LIKE @packageNamePattern
AND
e.execution_id = ISNULL(@executionIdFilter, e.execution_id)
ORDER BY
e.execution_id DESC
OPTION
(RECOMPILE);
-- Show successfull execution history
SELECT TOP 15
e.execution_id,
e.project_name,
e.package_name,
e.project_lsn,
e.status,
status_desc = CASE e.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,
e.start_time,
e.end_time,
elapsed_time_min = datediff(mi, e.start_time, e.end_time)
FROM
catalog.executions e
WHERE
e.status IN (2,7)
AND
e.package_name = @packageName
ORDER BY
e.execution_id DESC
;
-- Show error messages
SELECT
*
FROM
catalog.event_messages em
WHERE
em.operation_id = @executionId
AND
em.event_name = 'OnError'
ORDER BY
em.event_message_id DESC
;
-- Show warnings for duplicate lookups
SELECT
*
FROM
catalog.event_messages em
WHERE
em.operation_id = @executionId
AND
em.event_name = 'OnWarning'
AND
message LIKE '%duplicate%'
ORDER BY
em.event_message_id DESC
;
-- Show warnings for memory allocations
SELECT
*
FROM
catalog.event_messages em
WHERE
em.operation_id = @executionId
AND
em.event_name = 'OnInformation'
AND
message LIKE '%memory allocation%'
ORDER BY
em.event_message_id DESC
;
-- Show warnings for low virtual memory
SELECT
*
FROM
catalog.event_messages em
WHERE
em.operation_id = @executionId
AND
em.event_name = 'OnInformation'
AND
message LIKE '%low on virtual memory%'
ORDER BY
em.event_message_id DESC
;