SQLTeam.com | Weblogs | Forums

Accessing network drive for deleting/storing backup file


#1

Could any one tell me, what will be the query to delete the old backup file from a network location and store the backup in the same network location.


#2

If you want to delete a disk file from T-SQL you will need to use the xp_cmdshell command. You can create the scripts to delete the existing files and copy the new files yourself, but perhaps an easier option would be to use the maintenance plan wizard in SQL Server. You can access maintenance plan wizard from SQL Server Management Studio after connecting to the server and opening up the Management -> Maintenance Plans node in object explorer.

There are other options as well for setting up your backup files and purging old ones. The scripts by Ola Hallengren and the Minion backup/restore scripts are very good.


#3

You are absolutely right, but here we want to access the drive over LAN i.e., network location.


#4

You can create network drive and can use it in xp_cmdshell

Please refer the link: