How can I change @BackupDirectory and @CleanupTime after install #695
-
I installed the Is there a way to remove the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I didn't realize there was an UNINSTALL script on Ola's FAQ page. I was able to completely remove the SQL Server Maintenance Solution and install it again with the correct defaults. |
Beta Was this translation helpful? Give feedback.
-
the only 'problem' with that uninstall script is that it will also delete all the schedules of the jobs, if you have set them up already. i guess you can prevent that by amending the uninstall script and add the EXECUTE msdb.dbo.sp_delete_job @job_name = 'CommandLog Cleanup', @delete_unused_schedule = 0 the other option is to amend the MaintenanceSolution.sql script so you can just rerun it: IF @CurrentJobStepSubSystem IS NOT NULL AND @CurrentJobStepCommand IS NOT NULL AND NOT EXISTS (SELECT * FROM msdb.dbo.sysjobs WHERE [name] = @CurrentJobName)
BEGIN
EXECUTE msdb.dbo.sp_add_job @job_name = @CurrentJobName, @description = @JobDescription, @category_name = @JobCategory, @owner_login_name = @JobOwner
EXECUTE msdb.dbo.sp_add_jobstep @job_name = @CurrentJobName, @step_name = @CurrentJobName, @subsystem = @CurrentJobStepSubSystem, @command = @CurrentJobStepCommand, @output_file_name = @CurrentOutputFileName, @database_name = @CurrentJobStepDatabaseName
EXECUTE msdb.dbo.sp_add_jobserver @job_name = @CurrentJobName
END with IF @CurrentJobStepSubSystem IS NOT NULL AND @CurrentJobStepCommand IS NOT NULL
BEGIN
IF NOT EXISTS (SELECT * FROM msdb.dbo.sysjobs WHERE [name] = @CurrentJobName)
BEGIN
EXECUTE msdb.dbo.sp_add_job @job_name = @CurrentJobName, @description = @JobDescription, @category_name = @JobCategory, @owner_login_name = @JobOwner
EXECUTE msdb.dbo.sp_add_jobstep @job_name = @CurrentJobName, @step_name = @CurrentJobName, @subsystem = @CurrentJobStepSubSystem, @command = @CurrentJobStepCommand, @output_file_name = @CurrentOutputFileName, @database_name = @CurrentJobStepDatabaseName
EXECUTE msdb.dbo.sp_add_jobserver @job_name = @CurrentJobName
END
ELSE
BEGIN
PRINT 'update ' + @CurrentJobName + ' ' + @CurrentJobStepCommand
EXECUTE msdb.dbo.sp_update_jobstep @job_id = NULL, @job_name = @CurrentJobName, @step_id = 1, @step_name = @CurrentJobName, @subsystem = @CurrentJobStepSubSystem, @command = @CurrentJobStepCommand, @output_file_name = @CurrentOutputFileName, @database_name = @CurrentJobStepDatabaseName
END
END if your SQL Server is on Linux you need to amend an extra piece of code to get this working: IF @HostPlatform = 'Windows'
BEGIN
SELECT @CleanupTime = Value
FROM #Config
WHERE [Name] = 'CleanupTime'
END with SELECT @CleanupTime = Value
FROM #Config
WHERE [Name] = 'CleanupTime' i really have no clue why this @HostPlatform check is here tbh, doesn't seem to make sense (to me) |
Beta Was this translation helpful? Give feedback.
I didn't realize there was an UNINSTALL script on Ola's FAQ page. I was able to completely remove the SQL Server Maintenance Solution and install it again with the correct defaults.