Click here to monitor SSC
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
Valued Member
Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)

Group: General Forum Members
Points: 57 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
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1423 Visits: 6278
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
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8825 Visits: 16561
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