x

In net all the scripts are for VBS Script ie name.vbs

I want a script to delete old backup. In net all the scripts are for VBS Script ie name.vbs

Now when I create a job and in steps I select VBSCRIPT, it does not allow me to create the job ...

Kindly help
more ▼

asked Oct 25, 2010 at 10:25 PM in Default

chana gravatar image

chana
49 8 9 9

I think there are several non-VBS solutions on the net to remove backup files. At this moment, there is a discussion on this site about removing old backups which has several non-VBS solutions:

http://ask.sqlservercentral.com/questions/26934/please-provide-a-script-which-will-delete-old-back
Oct 26, 2010 at 06:50 AM KenJ
(comments are locked)
10|1200 characters needed characters left

1 answer: sort oldest

hi this script is in .sql , ithink this help s you to delete the old data

Option Explicit
'Delete all SQL Server backup files more than 1 days old
Dim oFS, oSQLBackupFol, oFol, oFil
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oSQLBackupFol = oFS.GetFolder("D:\SQL Server Backups") ' Change this to the right path
For Each oFol IN oSQLBackupFol.SubFolders
  For Each oFil in oFol.Files
       If oFil.DateCreated < Now-1 Then
             'If you want to make sure it's a .bak or .trn file, check oFil.Name, otherwise
             'This will delete anything more than a day old in the directory
             'all first level subdirectories.  (Recursion is left as an exercise for the reader)
              oFil.Delete                
        End If
  Next
Next
more ▼

answered Oct 26, 2010 at 06:31 AM

ramesh 1 gravatar image

ramesh 1
2.2k 63 67 69

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x88
x86
x9

asked: Oct 25, 2010 at 10:25 PM

Seen: 838 times

Last Updated: Oct 26, 2010 at 12:51 AM