Guest User

Untitled

a guest
Jan 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. Msg 22049, Sev 16, State 1: xp_delete_file() returned error 2, 'The system cannot find the file specified.' [SQLSTATE 42000]
  2. 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
  3.  
  4. Msg 22049, Sev 16, State 1: xp_delete_file() returned error 2, 'The system cannot find the file specified.' [SQLSTATE 42000]
  5.  
  6. -This will set the date time stamp to pass onto the Stored Proc for 72 hours from the current date when it runs
  7. --The stored proc will recursively delete all TRN files from the parent level specified all the way down
  8. declare @DeleteDate nvarchar(50)
  9. declare @DeleteDateTime datetime
  10. set @DeleteDateTime = DateAdd(hh, -72, GetDate())
  11. set @DeleteDate = (Select Replace(Convert(nvarchar, @DeleteDateTime, 111), '/', '-') + 'T' + Convert(nvarchar, @DeleteDateTime, 108))
  12.  
  13. --5th argument below "0 - don't delete recursively (default)" and "1 - delete files in sub directories"
  14. EXECUTE master.dbo.xp_delete_file 0,N'\homerS_SYSTEMSFullBackupsMY_SERVER_log1',N'trn', @DeleteDate,1
  15.  
  16. --5th argument below "0 - don't delete recursively (default)" and "1 - delete files in sub directories"
  17. EXECUTE master.dbo.xp_delete_file 0,N'\homerS_SYSTEMSFullBackupsMY_SERVER_log12',N'trn', @DeleteDate,1
Add Comment
Please, Sign In to add comment