Skip to content

Commit 57f49da

Browse files
committed
fix for #9553
1 parent 3dba5fd commit 57f49da

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

public/Install-DbaMaintenanceSolution.ps1

+17-7
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function Install-DbaMaintenanceSolution {
9090
https://ola.hallengren.com
9191
9292
.LINK
93-
https://dbatools.io/Install-DbaMaintenanceSolution
93+
https://dbatools.io/Install-DbaMaintenanceSolution
9494
9595
.EXAMPLE
9696
PS C:\> Install-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA -InstallJobs -CleanupTime 72
@@ -402,12 +402,6 @@ function Install-DbaMaintenanceSolution {
402402
$cleanupQuery = $null
403403
if ($ReplaceExisting) {
404404
[string]$cleanupQuery = $("
405-
IF OBJECT_ID('[dbo].[CommandLog]', 'U') IS NOT NULL
406-
DROP TABLE [dbo].[CommandLog];
407-
IF OBJECT_ID('[dbo].[QueueDatabase]', 'U') IS NOT NULL
408-
DROP TABLE [dbo].[QueueDatabase];
409-
IF OBJECT_ID('[dbo].[Queue]', 'U') IS NOT NULL
410-
DROP TABLE [dbo].[Queue];
411405
IF OBJECT_ID('[dbo].[CommandExecute]', 'P') IS NOT NULL
412406
DROP PROCEDURE [dbo].[CommandExecute];
413407
IF OBJECT_ID('[dbo].[DatabaseBackup]', 'P') IS NOT NULL
@@ -418,6 +412,22 @@ function Install-DbaMaintenanceSolution {
418412
DROP PROCEDURE [dbo].[IndexOptimize];
419413
")
420414

415+
if ($LogToTable) {
416+
$cleanupQuery += $("
417+
IF OBJECT_ID('[dbo].[CommandLog]', 'U') IS NOT NULL
418+
DROP TABLE [dbo].[CommandLog];
419+
")
420+
}
421+
422+
if ($InstallParallel) {
423+
$cleanupQuery += $("
424+
IF OBJECT_ID('[dbo].[QueueDatabase]', 'U') IS NOT NULL
425+
DROP TABLE [dbo].[QueueDatabase];
426+
IF OBJECT_ID('[dbo].[Queue]', 'U') IS NOT NULL
427+
DROP TABLE [dbo].[Queue];
428+
")
429+
}
430+
421431
if ($Pscmdlet.ShouldProcess($instance, "Dropping all objects created by Ola's Maintenance Solution")) {
422432
Write-ProgressHelper -ExcludePercent -Message "Dropping objects created by Ola's Maintenance Solution"
423433
$null = $db.Invoke($cleanupQuery)

0 commit comments

Comments
 (0)