-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOla Hallengren_Jobs.sql
More file actions
29 lines (22 loc) · 1.24 KB
/
Ola Hallengren_Jobs.sql
File metadata and controls
29 lines (22 loc) · 1.24 KB
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
EXECUTE admindb.[dbo].[DatabaseBackup]
@Databases = 'Northwind',
@Directory = 'C:\_SQLbackup', -- Dein Backup-Pfad (idealerweise ein Share)
@BackupType = 'LOG', -- 'FULL', 'DIFF', oder 'LOG'
@Verify = 'Y', -- Wichtig: Backup nach dem Schreiben prüfen
@Compress = 'Y', -- Kompression spart Platz und I/O
@CheckSum = 'Y', -- Integritätsprüfung während des Backups
@CleanupTime = 168, -- Löscht Backups, die älter als 7 Tage (168h) sind
@LogToTable = 'Y' -- Protokolliert den Erfolg in CommandLog
select * from dbo.CommandLog
where CommandType = 'DatabaseBackup'
EXECUTE [AdminDB].[dbo].[IndexOptimize]
@Databases = 'Northwind',
@FragmentationLow = NULL, -- Unter 5% machen wir gar nichts (schont Ressourcen)
@FragmentationMedium = 'INDEX_REORGANIZE',
@FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE', -- Online bevorzugt (Edition-abhängig)
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 30,
@UpdateStatistics = 'ALL', -- Statistiken sind oft wichtiger als die Fragmentierung!
@OnlyModifiedStatistics = 'Y', -- Nur Statistiken updaten, wenn sich Daten geändert haben
@LogToTable = 'Y'
select * from dbo.CommandLog