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.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Maintenance Cleanup Task did not do its job

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2013-08-13 : 10:31:27
Hi,

Something is not right, because the scheduled job did not delete the older .bak files, even though the history did not indicate it errored out.

Here is it in sql view, and it got this error in query window
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '\'.

EXECUTE master.dbo.xp_delete_file 0,N''E:\Data'',N''.bak'',N''2013-07-30T00:25:10'',1

GO

I don't think it is folder permission, because other part of the plan runs full backup at the same drive.

Thanks!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-08-13 : 11:59:03
Shouldn't it be single quotes around the parameters and not double quotes? I don't use maintenance plans, so I am not sure.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2013-08-13 : 12:17:05
You are right. I saw another variation as follow:

EXECUTE master.dbo.xp_delete_file 0,N'E:\Data',N'.bak',N'2013-07-30T11:11:23',1

This is from within the Modify, edit window, View T-SQL.
This one run successfully from my local ssms querry session, BUT did not remove the files either.

The earlier version is copied from the history window.

I would like to hear your alternative way of clean up older files.

Thanks!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-08-13 : 12:35:24
The alternative is to use custom scripts. My version is on my blog. It's embedded into isp_Backup. Ola Hallengren also has scripts. Due to being super busy at work, I've slacked off on my blog and have stopped supporting isp_Backup and isp_ALTER_INDEX for code changes.

You could try recreating that portion of the maintenance plan as I have seen that as a solution to the issue you are reporting.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jeffw8713
Aged Yak Warrior

819 Posts

Posted - 2013-08-13 : 14:38:33
EXECUTE master.dbo.xp_delete_file 0,N'E:\Data',N'.bak',N'2013-07-30T11:11:23',1

should be

EXECUTE master.dbo.xp_delete_file 0,N'E:\Data',N'bak',N'2013-07-30T11:11:23',1

By including the . in the extension, the system is trying to delete files with an extension of '..bak' and is not finding any files.
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2013-08-13 : 16:17:36
Great catch!
Thank you, Jeff!

quote:
Originally posted by jeffw8713

EXECUTE master.dbo.xp_delete_file 0,N'E:\Data',N'.bak',N'2013-07-30T11:11:23',1

should be

EXECUTE master.dbo.xp_delete_file 0,N'E:\Data',N'bak',N'2013-07-30T11:11:23',1

By including the . in the extension, the system is trying to delete files with an extension of '..bak' and is not finding any files.

Go to Top of Page
   

- Advertisement -