Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Msg 22049, Sev 16, State 1: xp_delete_file() returned error 2, 'The system cannot find the file specified.' [SQLSTATE 42000]
- Job 'Log Shipping - Delete tran backups older than 3 days' : Step 1, 'delete the trn files older than 3 days' : Began Executing 2019-01-18 23:00:02
- Msg 22049, Sev 16, State 1: xp_delete_file() returned error 2, 'The system cannot find the file specified.' [SQLSTATE 42000]
- -This will set the date time stamp to pass onto the Stored Proc for 72 hours from the current date when it runs
- --The stored proc will recursively delete all TRN files from the parent level specified all the way down
- declare @DeleteDate nvarchar(50)
- declare @DeleteDateTime datetime
- set @DeleteDateTime = DateAdd(hh, -72, GetDate())
- set @DeleteDate = (Select Replace(Convert(nvarchar, @DeleteDateTime, 111), '/', '-') + 'T' + Convert(nvarchar, @DeleteDateTime, 108))
- --5th argument below "0 - don't delete recursively (default)" and "1 - delete files in sub directories"
- EXECUTE master.dbo.xp_delete_file 0,N'\homerS_SYSTEMSFullBackupsMY_SERVER_log1',N'trn', @DeleteDate,1
- --5th argument below "0 - don't delete recursively (default)" and "1 - delete files in sub directories"
- EXECUTE master.dbo.xp_delete_file 0,N'\homerS_SYSTEMSFullBackupsMY_SERVER_log12',N'trn', @DeleteDate,1
Add Comment
Please, Sign In to add comment