Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server xp_delete_file parameters

Who can explain list of xp_Delete_file parameters in sql server. I don't find msdn document for this stored procedure.

I got script of xp_Delete_file from maintenance plan but didn't understand first parameter.

like image 468
mehdi lotfi Avatar asked Jul 05 '14 04:07

mehdi lotfi


People also ask

What is Xp_delete_file?

xp_delete_file is an undocumented Extended Stored Procedure. You need to remember that it might not exists in future version or even after an update of the version, and since it is undocumented, no one will inform you that it was removed. You must use it with a lot of carful and on your own responsivity!


2 Answers

xp_delete_file take five parameters:

  1. File Type = 0 for backup files or 1 for report files.
  2. Folder Path = The folder to delete files. The path must end with a backslash "".
  3. File Extension = This could be 'BAK' or 'TRN' or whatever you normally use.
  4. Date = The cutoff date for what files need to be deleted.
  5. Subfolder = 0 to ignore subfolders, 1 to delete files in subfolders.

Source How to Use xp_delete_file to Purge Old Backup Files by Patrick Keisler

like image 185
M.Ali Avatar answered Sep 20 '22 06:09

M.Ali


Following on from the comment above, I have been testing this on SQL Server 2012 SP4 and I can confirm the syntax EXEC master.dbo.xp_delete_file 0, 'C:\Some Path\Backup file.bak' works and deletes the specific named file.

like image 26
Ubercoder Avatar answered Sep 19 '22 06:09

Ubercoder