Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have created maintenance plans for the database backup. all jobs working fine like backup job, history clean job, backup file cleanup job, but maintenance cleanup job for deleting the text file is not working fine. after some days i seen the folder is full of text files. my maintenance plan retention period is 2 days. i am using sql server 2005.
Posted

1 solution

Probably not a real good idea but there's always the TSQL workaround:
EXECUTE xp_cmdshell 'DEL (...)'

If you're certain of the location of these .txt logs, this simple shotgun approach is easy.

That MSDOS command help looks like:
Deletes one or more files.
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
  names         Specifies a list of one or more files or directories.
                Wildcards may be used to delete multiple files. If a
                directory is specified, all files within the directory
                will be deleted.
  /P            Prompts for confirmation before deleting each file.
  /F            Force deleting of read-only files.
  /S            Delete specified files from all subdirectories.
  /Q            Quiet mode, do not ask if ok to delete on global wildcard
  /A            Selects files to delete based on attributes
  attributes    R  Read-only files            S  System files
                H  Hidden files               A  Files ready for archiving
                I  Not content indexed Files  L  Reparse Points
                -  Prefix meaning not
If Command Extensions are enabled DEL and ERASE change as follows:
The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.

How I see it is that use of BCP and other SQL utilities shouldn't be a big deal as long as this database isn't in production or online allowing general access rights.

You do understand that Maintenance Plan requires sysadmin rights?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900