SQL Server: Delete Backup History, Purge Job History, and Maintenance Plan Logs
The provided code is not valid. Here's the corrected version:
DECLARE @dt DATETIME;
SET @dt = CAST('2023-09-18T21:53:00' AS DATETIME);
EXEC msdb.dbo.sp_delete_backuphistory @dt;
EXEC msdb.dbo.sp_purge_jobhistory @oldest_date = '2023-09-18T21:53:00';
EXEC msdb.dbo.sp_maintplan_delete_log NULL, NULL, '2023-09-18T21:53:00';
This code declares a variable @dt of type DATETIME and assigns it the value '2023-09-18T21:53:00'. Then it executes the stored procedures sp_delete_backuphistory, sp_purge_jobhistory, and sp_maintplan_delete_log with the specified parameters.
原文地址: https://www.cveoy.top/t/topic/bdWn 著作权归作者所有。请勿转载和采集!