SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Question on sp_delete_backuphistory


Question on sp_delete_backuphistory

Author
Message
MSSQL_NOOB
MSSQL_NOOB
SSC Veteran
SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)

Group: General Forum Members
Points: 269 Visits: 173
If I have the following:
SET @deleteday= dateadd(dd,-3,getdate())
EXEC msdb.dbo.sp_delete_backuphistory @deleteday


In the folder, currently have backups for 01/13/2013, 01/14/2013, 01/15/2013
So when the job runs, it'll delete 01/13/2013 backup from the folder.

Scenario
If I change the day from -3 to -4 before the clean up job runs tonight, the job won't delete 01/13/2013 because it's looking for 01/12/2013.
From @deleteday= dateadd(dd,-3,getdate())
To @deleteday= dateadd(dd,-4,getdate())


And if I change the day tomorrow back from -4 to -3
From @deleteday= dateadd(dd,-4,getdate())
To @deleteday= dateadd(dd,-3,getdate())

it'll essentially be looking for 1/14/2013.

My question is, will it delete 1/13/2013 AND 1/14/2013 backups? Or will it just delete 1/14/2013 backup and keep the 1/13/2013?

Thanks!
Ian Scarlett
Ian Scarlett
SSCertifiable
SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)

Group: General Forum Members
Points: 5376 Visits: 7144
It will delete both.

The parameter you are passing to sp_delete_backuphistory is telling it to delete ALL backup history OLDER than that date.



Perry Whittle
Perry Whittle
SSC Guru
SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)

Group: General Forum Members
Points: 54929 Visits: 17694
sp_delete_backuphistory deletes backup history from the MSDB backup history tables, it doesnt touch the filesystem!!

You're referring to xp_delete_file to achieve this

-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs" ;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search