SQL Server 2005 Maintenance Mayhem

  • Comments posted here are about the content posted at http://www.sqlservercentral.com/columnists/rpearl/2953.asp

  • The script posted in this article should come with a big warning: "The xp_delete_file procedure is undocumented and therefore unsupported!".

    Here is what a MS employee (Terrence Nevins, SQL Server Program Manager) has to say about it: "The stored procedure was never intended to be called by an end user and the chances that you could ever be successful in having it do what you intend are almost zero. I took a quick peek at the implementation we are using and it takes some very specialzed arguments for a very specific task. [...] We don't document this XP or promote its usage by anyone for very good reasons. Most of all, they can 'go away' from release to release."

    Source:

    https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=255121

    Razvan

  • Note that it didn't work while trying to delete files "across the network". but that does not means that it will never work.


    * Noel

  • I found that while the delete older than function in the wizard did not work, I could create a maintenance plan and then just add a maintenance cleanup task to the job. I can specify which directory to delete from, what type of files to delete, and how many days should remain.

    This has worked well for me.


    Regards,

    Carla Hepker
    Documentation: A Shaft of light into a coded world.

  • Hi, All:

    Thank you for your comments and reading my article.  It was meant to provide some interim solution to the maintenance issue. 

    The xp_delete_file is I believe used in the maintenance clean-up task, but didn't work for multiple db's for multiple locations (ie subfolders).  So, this was an extension of that task.

    Granted, a disclaimer should have been included in the article (maybe it's not too late - Steve?) as with all scripts, one must be aware there are risks.

    As for not working over the network, my backups are only to a network share and works quite well.

    Feel free to post any questions, or comments, or email me @ rsp05@pearlknows.com

    Regards,

    Robert Pearl

     

     

  • Robert,

    Thanks a lot for sharing the code.  It works for me after I replacing the following assignment statement in the code:

    from: set @mpath='Backup File Path' + @dir + '\' + @dbname

    to: set @mpath=@dir + '\' + @dbname

    I really appreciate your sharing to help me to resolve the same issue I encounter.

    Thanks again.

    Michele

     

  • Hi, I was trying to use xp_delete_file in one of my stored procedure. I was tryign to pass all the parameters like folderPath, FileType and Date to delete the files from specific folder. If I put FileType and Date as parameter with xp_delete_file, its works like

    EXECUTE master.dbo.xp_delete_file 0,N'C:\Test\',@fileType,@cutoffDate,0

    But if I try

    EXECUTE master.dbo.xp_delete_file 0,@folderPath,@fileType,@cutoffDate,0

    I get the error Msg 22049, Level 15, State 0, Line 0

    Error executing extended stored procedure: Invalid Parameter

    Any help will be appriciated

  • I figured out what the problem was.

    I was declaring the variable having the datatype NVARCHAR, where they should be declared as VARCHAR 🙁

    Thanks

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply