1
- USE ssisdb
2
- GO
3
- -- default log retention is 180 days. For frequently-running SSIS packagse, this could generate 100Gb+ data in months
4
- -- But changing the log retention time frame drastically could cause the built-in sprocs to try and delete 100Gb+ at once
5
- -- Instead, step down the retention in small chunks. This could still take HOURS to complete and block other SSIS jobs
6
- -- from logging, so recommended to create a maintainence window and stop SSISDB jobs from executing.
1
+ /*
2
+ Default log retention is 180 days. For frequently-running SSIS packages, this could generate 100Gb+ data in months
3
+ But changing the log retention time frame drastically could cause the built-in sprocs to try and delete 100Gb+ at once
4
+ Instead, step down the retention in small chunks. This could still take HOURS to complete and block other SSIS jobs
5
+ from logging, so recommended to create a maintainence window and stop SSISDB jobs from executing.
6
+ The script calls two stored procedure which are called by the SQL Agent job [SSIS Server Maintenance Job] at midnight by default.
7
7
8
- -- FYI: a bug in [internal].[cleanup_server_retention_window] prevents large deletes from succeeding.
9
- -- You'll see error message: "A cursor with the name 'execution_cursor' does not exist. [SQLSTATE 34000] (Error 16916)."
10
- -- More info: https://feedback.azure.com/forums/908035-sql-server/suggestions/37360864-ssis-server-maintenance-job-fails
11
- -- Fixed version is in comment block below. Careful!
8
+ FYI: a bug in [internal].[cleanup_server_retention_window] may prevent some large deletes from succeeding.
9
+ You'll see error message: "A cursor with the name 'execution_cursor' does not exist. [SQLSTATE 34000] (Error 16916)."
10
+ More info: https://feedback.azure.com/forums/908035-sql-server/suggestions/37360864-ssis-server-maintenance-job-fails
11
+ Fixed version is in comment block below. Careful!
12
12
13
+ */
14
+ USE ssisdb
15
+ GO
13
16
14
17
declare @current int , @desired int
15
18
@@ -30,12 +33,15 @@ BEGIN
30
33
END
31
34
32
35
/*
33
- --bugfix
36
+ --Potential needed bugfix for SQL 2017
37
+ --don't copy-replace this, it might be different on your version of SQL!
38
+ --Look for the comment below "This line moved"
39
+
34
40
USE [SSISDB]
35
41
GO
36
42
37
43
38
- ALTER PROCEDURE [internal].[cleanup_server_retention_window]
44
+ CREATE PROCEDURE [internal].[cleanup_server_retention_window]
39
45
WITH EXECUTE AS 'AllSchemaOwner'
40
46
AS
41
47
SET NOCOUNT ON
202
208
CLOSE execution_cursor
203
209
TRUNCATE TABLE #deleted_ops
204
210
END
205
- DEALLOCATE execution_cursor
211
+ DEALLOCATE execution_cursor --This line moved
206
212
DROP TABLE #deleted_ops
207
213
END
208
214
0 commit comments