question

chana avatar image
chana asked

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
sql-agentjobvbscript
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KenJ avatar image KenJ commented ·
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
0 Likes 0 ·

1 Answer

·
ramesh 1 avatar image
ramesh 1 answered
**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
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.