Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
CanadaDBA
583 Posts |
Posted - 2009-03-04 : 09:04:44
|
SQL Server 2k5 64bitI have a maintenance plan to delete BAK files older than 2 days. The job starts at 8:30pm everyday. But I see three BAK files in the folder rather than only 2. Here is an example of a database backup I see at the moment:Admin_backup_200903012030.bakAdmin_backup_200903022030.bakAdmin_backup_200903032030.bakThe first one should have been dropped when the third one was created. Why this happens? Is it a bug in SQL 2k5 64bit?Canada DBA |
|
CanadaDBA
583 Posts |
Posted - 2009-03-04 : 09:50:39
|
I had the same issue with "delete BAK files older than 1 day" and I had to change it to older than "23 hours" to force it work. But can't undrestand why it is like that? My SQL Server version is 9.0.4035.Canada DBA |
 |
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2009-03-04 : 10:37:13
|
Hello;I use this piece of code in my queries to delete information older than 2 days and have no problems with it.WHERE date_time > DATEADD(day, DATEDIFF(day, 0, GETDATE())-2,0)I am not sure why your's doesn't work as you didn't post any code. It could be that yours drills down to hours so the remaining entries fall outside of a 48 hour period.Mine looks at days and deletes everything 2 days older than the current day (hence the -2 value in the function call).r&r |
 |
|
subhash chandra
Starting Member
40 Posts |
Posted - 2009-03-04 : 14:02:23
|
The setting "Older than 2 days" is to delete files that are created before 12:00 AM of 2 days before. For example today is 03/04/09 then files created before 03/02/09 12:00 AM will be deleted. |
 |
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2009-03-04 : 14:30:21
|
quote: Originally posted by subhash chandra The setting "Older than 2 days" is to delete files that are created before 12:00 AM of 2 days before. For example today is 03/04/09 then files created before 03/02/09 12:00 AM will be deleted.
This is incorrect.In my query there is a field called date_time. The Where clause I supplied is not saying "delete everything prior to 2 days". It is saying "Look at the date_time field, if it is older than the last two days (hence the > operator) then do something with it (like delete the record).The original poster would need to use similar logic.r&r |
 |
|
subhash chandra
Starting Member
40 Posts |
Posted - 2009-03-04 : 15:18:12
|
quote: Originally posted by subhash chandra The setting "Older than 2 days" is to delete files that are created before 12:00 AM of 2 days before. For example today is 03/04/09 then files created before 03/02/09 12:00 AM will be deleted.
I suppose this functionality and not assure about it. I will reconfirm it after testing. |
 |
|
|
|
|